Просмотр исходного кода

Fixed crash if there are no devices available
(cherry picked from commit 679582e702bef0ccd743f07dab860ebce8912856)

Sam Lantinga 3 лет назад
Родитель
Сommit
abac672a2d
1 измененных файлов с 2 добавлено и 0 удалено
  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));