[FFmpeg-devel] [PATCH] h264_parser: fix memory leak

Rafaël Carré rafael.carre
Thu Jan 28 12:49:05 CET 2010


I noticed h264 parser was leaking a rbsp_buffer (reproducible with
ffplay under valgrind if you can find it through all the sdl/alsa
related messages)

This is freed in h264.c:free_tables(), which loops over all thread

First thread context is the decoder's context, set in decoder init.

This initialisation is missing in the parser so I added it. I suppose
other initialisations made in ff_h264_decode_init are useless in the
case of the parser.

Personally I would prefer just to not assume the context has set 
thread_context[0] with this smaller patch (assuming the parser will
not need to use thread_context at all)

diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index e4a47cf..f1a09c3 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -669,7 +669,7 @@ static void free_tables(H264Context *h){
     for(i = 0; i < MAX_THREADS; i++) {
-        hx = h->thread_context[i];
+        hx = i ? h->thread_context[i] : h;  /* parser doesn't use threads */
         if(!hx) continue;

Rafa?l Carr?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100128/00f3840a/attachment.pgp>

More information about the ffmpeg-devel mailing list