Commit 679582e702bef0ccd743f07dab860ebce8912856

Sam Lantinga 2022-08-25T11:07:20

Fixed crash if there are no devices available

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/src/hidapi/mac/hid.c b/src/hidapi/mac/hid.c
index cfad07c..35ca380 100644
--- a/src/hidapi/mac/hid.c
+++ b/src/hidapi/mac/hid.c
@@ -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));