Fixed crash if there are no devices available

(cherry picked from commit 679582e702)
This commit is contained in:
Sam Lantinga authored and Ozkan Sezer committed 2022-09-12 21:33:50 +03:00
1 parent 782862b95c
commit abac672a2d
1 file changed
+2
+2
View File
@@ -811,6 +811,8 @@ hid_device * HID_API_EXPORT hid_open_path(const char *path, int bExclusive)
process_pending_events();
device_set = IOHIDManagerCopyDevices(hid_mgr);
if (!device_set)
return NULL;
num_devices = CFSetGetCount(device_set);
device_array = (IOHIDDeviceRef *)calloc(num_devices, sizeof(IOHIDDeviceRef));