Andrew Eikum : xinput: Check for NULL argument in XInputGetState.

Alexandre Julliard julliard at winehq.org
Mon Sep 30 16:19:08 CDT 2019


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

Author: Andrew Eikum <aeikum at codeweavers.com>
Date:   Mon Sep 30 13:04:26 2019 -0500

xinput: Check for NULL argument in XInputGetState.

Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/xinput1_3/tests/xinput.c | 3 +++
 dlls/xinput1_3/xinput_main.c  | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/dlls/xinput1_3/tests/xinput.c b/dlls/xinput1_3/tests/xinput.c
index e5eb504d52..a6e2107446 100644
--- a/dlls/xinput1_3/tests/xinput.c
+++ b/dlls/xinput1_3/tests/xinput.c
@@ -126,6 +126,9 @@ static void test_get_state(void)
         }
     }
 
+    result = pXInputGetState(0, NULL);
+    ok(result == ERROR_BAD_ARGUMENTS, "XInputGetState returned (%d)\n", result);
+
     result = pXInputGetState(XUSER_MAX_COUNT, &state);
     ok(result == ERROR_BAD_ARGUMENTS, "XInputGetState returned (%d)\n", result);
 
diff --git a/dlls/xinput1_3/xinput_main.c b/dlls/xinput1_3/xinput_main.c
index 57337e09ad..a417fec7ad 100644
--- a/dlls/xinput1_3/xinput_main.c
+++ b/dlls/xinput1_3/xinput_main.c
@@ -88,6 +88,9 @@ DWORD WINAPI DECLSPEC_HOTPATCH XInputSetState(DWORD index, XINPUT_VIBRATION* vib
  * XInputGetState() in the hook, so we need a wrapper. */
 static DWORD xinput_get_state(DWORD index, XINPUT_STATE *state)
 {
+    if (!state)
+        return ERROR_BAD_ARGUMENTS;
+
     HID_find_gamepads(controllers);
 
     if (index >= XUSER_MAX_COUNT)




More information about the wine-cvs mailing list