瀏覽代碼

hidapi/mac: fixed crash on macOS when AirPods are connected

Signed-off-by: Sam Lantinga <slouken@libsdl.org>
Sam Lantinga 2 年之前
父節點
當前提交
2fa4b2e78f
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      src/hidapi/mac/hid.c

+ 4 - 1
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;