[FFmpeg-devel] Memory leak in h264

Michael Niedermayer michaelni
Tue Jan 22 19:39:49 CET 2008

On Tue, Jan 22, 2008 at 05:22:55PM +0200, Ian McIntosh wrote:
> Hi All
> Using the latest source from svn (updated this morning) I think there is 
> a memory leak with decoding h264. When opening, h264 will call the 
> function MPV_common_init() which in turn calls init_duplicate_context() 
> in mpegvideo.c. This allocates a buffer and stores the pointer in 
> s->allocated_edge_emu_buffer. Following this, h264 will then do its own 
> context initialisation in context_init() (from h264.c) which will again 
> allocate a buffer and overwrite the current s->allocated_edge_emu_buffer 
> pointer and so memory is lost. It seems to me the fix is to check  
> s->allocated_edge_emu_buffer!=NULL in context_init() before allocating - 
> but I am not certain whether this is 100% correct. I include snippets of 
> the source to help locate the relevant source lines within the files.

i suspect that will break multithreaded decoding by using the same buffer
for all threads

the fix might be to always let init_duplicate_context allocate all
the *edge_emu_buffer, instead of just for the first context and then
allocate the H264Contexts and copy the MpegEncContexts into them

Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Frequently ignored awnser#1 FFmpeg bugs should be sent to our bugtracker, user
questions for the command line tools ffmpeg, ffplay, ... as well as questions
about how to use libav* should be sent to the ffmpeg-user mailinglist.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080122/daf842a8/attachment.pgp>

More information about the ffmpeg-devel mailing list