[vlc-devel] [2.2 PATCH] avcodec: fix invalid free

Thomas Guillem thomas at gllm.fr
Tue Dec 8 16:21:36 CET 2015


Initialize frame to NULL before goto end

(cherry picked from commit 3fc28a0bc620ea3668181eb24ddb0b5f0d00e869)
---
 modules/codec/avcodec/audio.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/modules/codec/avcodec/audio.c b/modules/codec/avcodec/audio.c
index ae2f9dd..9dc8928 100644
--- a/modules/codec/avcodec/audio.c
+++ b/modules/codec/avcodec/audio.c
@@ -265,6 +265,7 @@ block_t * DecodeAudio ( decoder_t *p_dec, block_t **pp_block )
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
     AVCodecContext *ctx = p_sys->p_context;
+    AVFrame *frame = NULL;
 
     if( !pp_block || !*pp_block )
         return NULL;
@@ -312,11 +313,11 @@ block_t * DecodeAudio ( decoder_t *p_dec, block_t **pp_block )
     }
 
 #if (LIBAVCODEC_VERSION_MAJOR >= 55)
-    AVFrame *frame = av_frame_alloc();
+    frame = av_frame_alloc();
     if (unlikely(frame == NULL))
         goto end;
 #else
-    AVFrame *frame = &(AVFrame) { };
+    frame = &(AVFrame) { };
 #endif
 
     for( int got_frame = 0; !got_frame; )
-- 
2.1.4



More information about the vlc-devel mailing list