[FFmpeg-devel] [PATCH] Fix memory leaks on failed ff_h264_decode_init()

dalecurtis at chromium.org dalecurtis at chromium.org
Tue Apr 10 20:31:03 CEST 2012


From: Dale Curtis <dalecurtis at chromium.org>

During failure conditions ff_h264_decode_init() leaks memory
allocated for nal units.  Found via valgrind.

Valgrind traces: http://pastebin.com/GqTqxs8T

Signed-off-by: Dale Curtis <dalecurtis at chromium.org>
---
 libavcodec/h264.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index b909600..2903cf9 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -1251,8 +1251,10 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx)
     }
 
     if (avctx->extradata_size > 0 && avctx->extradata &&
-        ff_h264_decode_extradata(h, avctx->extradata, avctx->extradata_size) < 0)
+        ff_h264_decode_extradata(h, avctx->extradata, avctx->extradata_size) < 0) {
+        ff_h264_free_context(h);
         return -1;
+    }
 
     if (h->sps.bitstream_restriction_flag &&
         s->avctx->has_b_frames < h->sps.num_reorder_frames) {
-- 
1.7.7.3



More information about the ffmpeg-devel mailing list