Prechádzať zdrojové kódy

mac-capture: Fix potential crash querying devices

I didn't check to see if the size of the string was 0, when it's 0 it
won't create the converted string and it'll send a null pointer to
CFStringGetCString, causing it to crash.
jp9000 11 rokov pred
rodič
commit
6b8b5e5f64
1 zmenil súbory, kde vykonal 3 pridanie a 0 odobranie
  1. 3 0
      plugins/mac-capture/mac-helpers.h

+ 3 - 0
plugins/mac-capture/mac-helpers.h

@@ -24,6 +24,9 @@ static inline bool cf_to_dstr(CFStringRef ref, struct dstr *str)
 	if (!ref) return false;
 
 	size = (size_t)CFStringGetLength(ref);
+	if (!size)
+		return false;
+
 	dstr_resize(str, size);
 
 	return (bool)CFStringGetCString(ref, str->array, size+1,