Fix https://github.com/ValveSoftware/Proton/issues/2040.
Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- 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 cf3028a4ec..4bfccdfb84 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 14fd5f8f77..ffdd4b7137 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();