Browse Source

Fixed crash if there are no devices available

Sam Lantinga 2 years ago
parent
commit
679582e702
1 changed files with 2 additions and 0 deletions
  1. 2 0
      src/hidapi/mac/hid.c

+ 2 - 0
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));