From abac672a2d48373cff16718fbd5a729cca3573b1 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 25 Aug 2022 11:07:20 -0700 Subject: [PATCH] Fixed crash if there are no devices available (cherry picked from commit 679582e702bef0ccd743f07dab860ebce8912856) --- src/hidapi/mac/hid.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hidapi/mac/hid.c b/src/hidapi/mac/hid.c index cfad07c25..35ca38037 100644 --- a/src/hidapi/mac/hid.c +++ b/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));