]> git.sesse.net Git - vlc/commitdiff
avcodec: fix double free
authorRémi Denis-Courmont <remi@remlab.net>
Thu, 2 Oct 2014 18:41:40 +0000 (21:41 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Thu, 2 Oct 2014 20:00:56 +0000 (23:00 +0300)
modules/codec/avcodec/avcodec.c
modules/codec/avcodec/avcommon_compat.h

index 59be08155beaf8529ea3482b410527b6e498b6f5..232134aa5c2daf32f3b30e7bdb24996547a182cc 100644 (file)
@@ -341,7 +341,6 @@ static void CloseDecoder( vlc_object_t *p_this )
 
     decoder_sys_t *p_sys = p_dec->p_sys;
 
-    av_free( p_sys->p_context->extradata );
     avcodec_free_context( &p_sys->p_context );
     free( p_sys );
 }
index fb2396f315925b757b747bbe6ff5efa62425ebf3..e9612427404c6283182ea8f4933163285d00efa5 100644 (file)
 
 static inline void avcodec_free_context( AVCodecContext **ctx )
 {
-    av_freep( ctx );
+    if( !*ctx )
+        return;
+
+    av_free( (*ctx)->extradata );
+    av_free( *ctx );
+    *ctx = NULL;
 }
 #endif