mirror of
https://github.com/libretro/RetroArch
synced 2025-02-11 06:40:48 +00:00
Prevent double free and null dereference when the controller is quickly reconnected. Handle error when controller device query returns null instead of crashing.
This commit is contained in:
parent
24dc83cbda
commit
347ea8157c
@ -544,6 +544,7 @@ static void iohidmanager_hid_device_remove(IOHIDDeviceRef device, iohidmanager_h
|
|||||||
free(tmp);
|
free(tmp);
|
||||||
}
|
}
|
||||||
free(adapter);
|
free(adapter);
|
||||||
|
adapter = NULL;
|
||||||
}
|
}
|
||||||
RARCH_LOG("Device removed from port %d\n", slot);
|
RARCH_LOG("Device removed from port %d\n", slot);
|
||||||
}
|
}
|
||||||
@ -702,6 +703,10 @@ static void iohidmanager_hid_device_add(IOHIDDeviceRef device, iohidmanager_hid_
|
|||||||
|
|
||||||
/* scan for buttons, axis, hats */
|
/* scan for buttons, axis, hats */
|
||||||
elements_raw = IOHIDDeviceCopyMatchingElements(device, NULL, kIOHIDOptionsTypeNone);
|
elements_raw = IOHIDDeviceCopyMatchingElements(device, NULL, kIOHIDOptionsTypeNone);
|
||||||
|
|
||||||
|
if (!elements_raw)
|
||||||
|
goto error;
|
||||||
|
|
||||||
count = (int)CFArrayGetCount(elements_raw);
|
count = (int)CFArrayGetCount(elements_raw);
|
||||||
elements = CFArrayCreateMutableCopy(
|
elements = CFArrayCreateMutableCopy(
|
||||||
kCFAllocatorDefault,(CFIndex)count,elements_raw);
|
kCFAllocatorDefault,(CFIndex)count,elements_raw);
|
||||||
@ -940,6 +945,7 @@ error:
|
|||||||
free(tmp);
|
free(tmp);
|
||||||
}
|
}
|
||||||
free(adapter);
|
free(adapter);
|
||||||
|
adapter = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +63,9 @@ typedef struct
|
|||||||
|
|
||||||
static void free_autoconfig_handle(autoconfig_handle_t *autoconfig_handle)
|
static void free_autoconfig_handle(autoconfig_handle_t *autoconfig_handle)
|
||||||
{
|
{
|
||||||
|
if (!autoconfig_handle)
|
||||||
|
return;
|
||||||
|
|
||||||
if (autoconfig_handle->dir_autoconfig)
|
if (autoconfig_handle->dir_autoconfig)
|
||||||
{
|
{
|
||||||
free(autoconfig_handle->dir_autoconfig);
|
free(autoconfig_handle->dir_autoconfig);
|
||||||
@ -743,9 +746,7 @@ error:
|
|||||||
task = NULL;
|
task = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (autoconfig_handle)
|
free_autoconfig_handle(autoconfig_handle);
|
||||||
free_autoconfig_handle(autoconfig_handle);
|
|
||||||
autoconfig_handle = NULL;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -928,7 +929,6 @@ error:
|
|||||||
}
|
}
|
||||||
|
|
||||||
free_autoconfig_handle(autoconfig_handle);
|
free_autoconfig_handle(autoconfig_handle);
|
||||||
autoconfig_handle = NULL;
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user