Zhiyi Zhang : user32: Check for null handle in GetRawInputData().

Alexandre Julliard julliard at winehq.org
Thu Jan 24 14:42:53 CST 2019


Module: wine
Branch: master
Commit: bd730a5f412c1e3b8a05b3b297ca0642e23fb92b
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=bd730a5f412c1e3b8a05b3b297ca0642e23fb92b

Author: Zhiyi Zhang <zzhang at codeweavers.com>
Date:   Wed Jan 23 23:27:09 2019 +0800

user32: Check for null handle in GetRawInputData().

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46499
Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/user32/rawinput.c    |  3 +++
 dlls/user32/tests/input.c | 11 +++++++++++
 2 files changed, 14 insertions(+)

diff --git a/dlls/user32/rawinput.c b/dlls/user32/rawinput.c
index cf3028a..4bfccdf 100644
--- a/dlls/user32/rawinput.c
+++ b/dlls/user32/rawinput.c
@@ -281,6 +281,9 @@ UINT WINAPI GetRawInputData(HRAWINPUT rawinput, UINT command, void *data, UINT *
     TRACE("rawinput %p, command %#x, data %p, data_size %p, header_size %u.\n",
             rawinput, command, data, data_size, header_size);
 
+    if (!ri)
+        return ~0U;
+
     if (header_size != sizeof(RAWINPUTHEADER))
     {
         WARN("Invalid structure size %u.\n", header_size);
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c
index 14fd5f8..ffdd4b7 100644
--- a/dlls/user32/tests/input.c
+++ b/dlls/user32/tests/input.c
@@ -1530,6 +1530,16 @@ static void test_GetRawInputDeviceList(void)
     ok(odevcount == oret, "expected %d, got %d\n", oret, odevcount);
 }
 
+static void test_GetRawInputData(void)
+{
+    UINT size;
+    UINT ret;
+
+    /* Null raw input handle */
+    ret = GetRawInputData(NULL, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER));
+    ok(ret == ~0U, "Expect ret %u, got %u\n", ~0U, ret);
+}
+
 static void test_key_map(void)
 {
     HKL kl = GetKeyboardLayout(0);
@@ -2697,6 +2707,7 @@ START_TEST(input)
     test_attach_input();
     test_GetKeyState();
     test_OemKeyScan();
+    test_GetRawInputData();
 
     if(pGetMouseMovePointsEx)
         test_GetMouseMovePointsEx();




More information about the wine-cvs mailing list