Skip to content

Commit ce606fa

Browse files
macOS: check if IOHIDManagerCopyDevices returned a NULL (#209)
Removes a possible cause for a segmentation fault observed in `CFSetGetCount`. Related: #208 ("Segmentation fault on Mac OS Catalina"). Signed-off-by: Jonas Malaco <jonas@protocubo.io>
1 parent 48cacfa commit ce606fa

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

mac/hid.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,9 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
583583
}
584584

585585
CFSetRef device_set = IOHIDManagerCopyDevices(hid_mgr);
586+
if (device_set == NULL) {
587+
return NULL;
588+
}
586589

587590
/* Convert the list into a C array so we can iterate easily. */
588591
num_devices = CFSetGetCount(device_set);

0 commit comments

Comments
 (0)