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.
This commit is contained in:
jp9000 2015-01-05 14:11:33 -08:00
parent b120f7cc80
commit 6b8b5e5f64

View File

@ -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,