From: Maksym Khomenko Date: Wed, 31 May 2023 20:44:42 +0000 (+0300) Subject: decklink: Calculate string size before malloc X-Git-Tag: 1.22.7~230 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;ds=sidebyside;h=06587a61a1f42649b3c118a868fcace002ec089c;p=platform%2Fupstream%2Fgstreamer.git decklink: Calculate string size before malloc Part-of: --- diff --git a/subprojects/gst-plugins-bad/sys/decklink/gstdecklink.h b/subprojects/gst-plugins-bad/sys/decklink/gstdecklink.h index dd50e78..1c8881b 100644 --- a/subprojects/gst-plugins-bad/sys/decklink/gstdecklink.h +++ b/subprojects/gst-plugins-bad/sys/decklink/gstdecklink.h @@ -50,7 +50,15 @@ #include "osx/DeckLinkAPI.h" #define COMSTR_T CFStringRef -#define CONVERT_COM_STRING(s) G_STMT_START { CFStringRef _s = (CFStringRef)s; s = (char*) malloc(100); CFStringGetCString(_s, s, 100, kCFStringEncodingUTF8); CFRelease(_s); } G_STMT_END +#define CONVERT_COM_STRING(s) G_STMT_START { \ + CFStringRef _s = (CFStringRef)s; \ + CFIndex _length; \ + CFStringGetBytes(_s, CFRangeMake(0, CFStringGetLength(_s)), kCFStringEncodingUTF8, 0, FALSE, NULL, 0, &_length); \ + _length += 1; \ + s = (char *) malloc(_length); \ + CFStringGetCString(_s, s, _length, kCFStringEncodingUTF8); \ + CFRelease(_s); \ + } G_STMT_END #define FREE_COM_STRING(s) free(s); #define CONVERT_TO_COM_STRING(s) G_STMT_START { char * _s = (char *)s; s = CFStringCreateWithCString(kCFAllocatorDefault, _s, kCFStringEncodingUTF8); g_free(_s); } G_STMT_END #define WINAPI