소스 검색

Fixed crash if there are no devices available

Sam Lantinga 3 년 전
부모
커밋
679582e702
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));