[vlc-commits] avcodec: fix double free

Rémi Denis-Courmont git at videolan.org
Thu Oct 2 21:56:55 CEST 2014


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

avcodec: fix double free

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

 modules/codec/avcodec/avcodec.c         |    1 -
 modules/codec/avcodec/avcommon_compat.h |    5 ++++-
 2 files changed, 4 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..18c1c9e 100644
--- a/modules/codec/avcodec/avcommon_compat.h
+++ b/modules/codec/avcodec/avcommon_compat.h
@@ -42,7 +42,10 @@
 
 static inline void avcodec_free_context( AVCodecContext **ctx )
 {
-    av_freep( ctx );
+    if( *ctx )
+        av_free( (*ctx)->extradata );
+    av_free( ctx );
+    *ctx = NULL;
 }
 #endif
 



More information about the vlc-commits mailing list