Aric Stewart : dinput: Handle case where IOHIDDeviceGetValue fails.
Alexandre Julliard
julliard at winehq.org
Mon Nov 25 09:12:27 CST 2019
Module: wine
Branch: stable
Commit: d0a450a32c309d56ee9a1b36136019e37d9c280f
URL: https://source.winehq.org/git/wine.git/?a=commit;h=d0a450a32c309d56ee9a1b36136019e37d9c280f
Author: Aric Stewart <aric at codeweavers.com>
Date: Tue Jun 4 07:47:35 2019 -0500
dinput: Handle case where IOHIDDeviceGetValue fails.
This prevents crashes if a controller disconnects from OS/X.
Signed-off-by: Aric Stewart <aric at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit c5283300e10b289293203a02f765cf757e3e910e)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
dlls/dinput/joystick_osx.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/dlls/dinput/joystick_osx.c b/dlls/dinput/joystick_osx.c
index ad664342f6..f8074b180d 100644
--- a/dlls/dinput/joystick_osx.c
+++ b/dlls/dinput/joystick_osx.c
@@ -801,7 +801,11 @@ static void poll_osx_device_state(LPDIRECTINPUTDEVICE8A iface)
TRACE("kIOHIDElementTypeInput_Button\n");
if(button_idx < 128)
{
- IOHIDDeviceGetValue(hid_device, element, &valueRef);
+ valueRef = NULL;
+ if (IOHIDDeviceGetValue(hid_device, element, &valueRef) != kIOReturnSuccess)
+ return;
+ if (valueRef == NULL)
+ return;
val = IOHIDValueGetIntegerValue(valueRef);
newVal = val ? 0x80 : 0x0;
oldVal = device->generic.js.rgbButtons[button_idx];
@@ -823,7 +827,11 @@ static void poll_osx_device_state(LPDIRECTINPUTDEVICE8A iface)
case kHIDUsage_GD_Hatswitch:
{
TRACE("kIOHIDElementTypeInput_Misc / kHIDUsage_GD_Hatswitch\n");
- IOHIDDeviceGetValue(hid_device, element, &valueRef);
+ valueRef = NULL;
+ if (IOHIDDeviceGetValue(hid_device, element, &valueRef) != kIOReturnSuccess)
+ return;
+ if (valueRef == NULL)
+ return;
val = IOHIDValueGetIntegerValue(valueRef);
oldVal = device->generic.js.rgdwPOV[pov_idx];
if (val >= 8)
@@ -850,7 +858,11 @@ static void poll_osx_device_state(LPDIRECTINPUTDEVICE8A iface)
{
int wine_obj = -1;
- IOHIDDeviceGetValue(hid_device, element, &valueRef);
+ valueRef = NULL;
+ if (IOHIDDeviceGetValue(hid_device, element, &valueRef) != kIOReturnSuccess)
+ return;
+ if (valueRef == NULL)
+ return;
val = IOHIDValueGetIntegerValue(valueRef);
newVal = joystick_map_axis(&device->generic.props[idx], val);
switch (usage)
More information about the wine-cvs
mailing list