[vlc-commits] avcodec: fix double free

Rémi Denis-Courmont git at videolan.org
Thu Oct 2 22:00:59 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Oct  2 21:41:40 2014 +0300| [a9ac943471c67fb3416f21246e389decda12cc38] | committer: Rémi Denis-Courmont

avcodec: fix double free

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a9ac943471c67fb3416f21246e389decda12cc38
---

 modules/codec/avcodec/avcodec.c         |    1 -
 modules/codec/avcodec/avcommon_compat.h |    7 ++++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/modules/codec/avcodec/avcodec.c b/modules/codec/avcodec/avcodec.c
index 59be081..232134a 100644
--- a/modules/codec/avcodec/avcodec.c
+++ b/modules/codec/avcodec/avcodec.c
@@ -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 );
 }
diff --git a/modules/codec/avcodec/avcommon_compat.h b/modules/codec/avcodec/avcommon_compat.h
index fb2396f..e961242 100644
--- a/modules/codec/avcodec/avcommon_compat.h
+++ b/modules/codec/avcodec/avcommon_compat.h
@@ -42,7 +42,12 @@
 
 static inline void avcodec_free_context( AVCodecContext **ctx )
 {
-    av_freep( ctx );
+    if( !*ctx )
+        return;
+
+    av_free( (*ctx)->extradata );
+    av_free( *ctx );
+    *ctx = NULL;
 }
 #endif
 



More information about the vlc-commits mailing list