diff --git a/mac/hid.c b/mac/hid.c index e0756a15..fb2c0507 100644 --- a/mac/hid.c +++ b/mac/hid.c @@ -407,6 +407,8 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id, /* Get a list of the Devices */ IOHIDManagerSetDeviceMatching(hid_mgr, NULL); CFSetRef device_set = IOHIDManagerCopyDevices(hid_mgr); + if (device_set == NULL) + return NULL; /* Convert the list into a C array so we can iterate easily. */ num_devices = CFSetGetCount(device_set); @@ -1081,6 +1083,8 @@ int main(void) IOHIDManagerOpen(mgr, kIOHIDOptionsTypeNone); CFSetRef device_set = IOHIDManagerCopyDevices(mgr); + if (device_set == NULL) + return 0; CFIndex num_devices = CFSetGetCount(device_set); IOHIDDeviceRef *device_array = calloc(num_devices, sizeof(IOHIDDeviceRef));