Commit 2d809218 authored by Ken Thomases's avatar Ken Thomases Committed by Alexandre Julliard

dinput: Check array indexes to avoid exceeding array bounds.

parent ab872f2f
......@@ -186,7 +186,7 @@ static IOHIDDeviceRef get_device_ref(int id)
IOHIDElementRef device_main_element;
IOHIDDeviceRef hid_device;
if (!device_main_elements)
if (!device_main_elements || id >= CFArrayGetCount(device_main_elements))
return 0;
device_main_element = (IOHIDElementRef)CFArrayGetValueAtIndex(device_main_elements, id);
......@@ -325,8 +325,6 @@ static void get_element_children(IOHIDElementRef element, CFMutableArrayRef all_
CFArrayRef element_children = IOHIDElementGetChildren(element);
cnt = CFArrayGetCount(element_children);
if (cnt < 1)
return;
/* Either add the element to the array or grab its children */
for (idx=0; idx<cnt; idx++)
......@@ -454,7 +452,7 @@ static void get_osx_device_elements(JoystickImpl *device, int axis_map[8])
device->elements = NULL;
if (!device_main_elements)
if (!device_main_elements || device->id >= CFArrayGetCount(device_main_elements))
return;
device_main_element = (IOHIDElementRef)CFArrayGetValueAtIndex(device_main_elements, device->id);
......@@ -585,7 +583,7 @@ static void poll_osx_device_state(LPDIRECTINPUTDEVICE8A iface)
TRACE("polling device %i\n",device->id);
if (!device_main_elements)
if (!device_main_elements || device->id >= CFArrayGetCount(device_main_elements))
return;
device_main_element = (IOHIDElementRef) CFArrayGetValueAtIndex(device_main_elements, device->id);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment