From 2fa4b2e78f16da8c6126b62ba32eecd5632dcc1e Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 25 May 2023 08:53:45 -0700 Subject: [PATCH] hidapi/mac: fixed crash on macOS when AirPods are connected Signed-off-by: Sam Lantinga --- src/hidapi/mac/hid.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/hidapi/mac/hid.c b/src/hidapi/mac/hid.c index 5c0914a89c..280b3a9cbd 100644 --- a/src/hidapi/mac/hid.c +++ b/src/hidapi/mac/hid.c @@ -372,11 +372,14 @@ static int get_string_property(IOHIDDeviceRef device, CFStringRef prop, wchar_t if (!len) return 0; + if (CFGetTypeID(prop) != CFStringGetTypeID()) + return 0; + str = (CFStringRef) IOHIDDeviceGetProperty(device, prop); buf[0] = 0; - if (str) { + if (str && CFGetTypeID(str) == CFStringGetTypeID()) { CFIndex str_len = CFStringGetLength(str); CFRange range; CFIndex used_buf_len;