diff mbox

[FFmpeg-devel,1/4] avdevice/decklink: Fix segfault when running -list_devices on OSX

Message ID 20170926160623.1257-2-dheitmueller@ltnglobal.com
State Accepted
Commit b6782a192e18161f33fc5e943b6f33dcb97e7287
Headers show

Commit Message

Devin Heitmueller Sept. 26, 2017, 4:06 p.m. UTC
The string is allocated with CFStringGetCString but was being
deallocated with free(), which would intermittently result in
a segmentation fault.  Use the correct function for freeing the
allocated CFString.

Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com>
---
 libavdevice/decklink_common.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Marton Balint Oct. 4, 2017, 8:50 p.m. UTC | #1
On Tue, 26 Sep 2017, Devin Heitmueller wrote:

> The string is allocated with CFStringGetCString but was being
> deallocated with free(), which would intermittently result in
> a segmentation fault.  Use the correct function for freeing the
> allocated CFString.
>
> Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com>
> ---
> libavdevice/decklink_common.cpp | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp
> index cbb591ce64..7745575d0e 100644
> --- a/libavdevice/decklink_common.cpp
> +++ b/libavdevice/decklink_common.cpp
> @@ -84,7 +84,7 @@ static char *dup_cfstring_to_utf8(CFStringRef w)
> }
> #define DECKLINK_STR    const __CFString *
> #define DECKLINK_STRDUP dup_cfstring_to_utf8
> -#define DECKLINK_FREE(s) free((void *) s)
> +#define DECKLINK_FREE(s) CFRelease(s)
> #define DECKLINK_BOOL bool
> #else
> #define DECKLINK_STR    const char *

Thanks, appiled.

Regards,
Marton
diff mbox

Patch

diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp
index cbb591ce64..7745575d0e 100644
--- a/libavdevice/decklink_common.cpp
+++ b/libavdevice/decklink_common.cpp
@@ -84,7 +84,7 @@  static char *dup_cfstring_to_utf8(CFStringRef w)
 }
 #define DECKLINK_STR    const __CFString *
 #define DECKLINK_STRDUP dup_cfstring_to_utf8
-#define DECKLINK_FREE(s) free((void *) s)
+#define DECKLINK_FREE(s) CFRelease(s)
 #define DECKLINK_BOOL bool
 #else
 #define DECKLINK_STR    const char *