SDL: Fixed crash on macOS when AirPods are connected

From 1133ea03492006c766f3d92697558127fa5e122f Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 22 Mar 2021 19:18:57 -0700
Subject: [PATCH] Fixed crash on macOS when AirPods are connected

---
 src/hidapi/mac/hid.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/hidapi/mac/hid.c b/src/hidapi/mac/hid.c
index 70a2fb0d3..bdaa612ac 100644
--- a/src/hidapi/mac/hid.c
+++ b/src/hidapi/mac/hid.c
@@ -251,7 +251,10 @@ 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;
@@ -288,6 +291,9 @@ static int get_string_property_utf8(IOHIDDeviceRef device, CFStringRef prop, cha
 	if (!len)
 		return 0;
 	
+	if (CFGetTypeID(prop) != CFStringGetTypeID())
+		return 0;
+
 	str = (CFStringRef)IOHIDDeviceGetProperty(device, prop);
 	
 	buf[0] = 0;