[FFmpeg-devel] Memory leak using bitstream filters with shared libs

Reimar Döffinger Reimar.Doeffinger
Sun Mar 9 19:50:16 CET 2008


On Sun, Mar 09, 2008 at 12:05:33AM +0000, M?ns Rullg?rd wrote:
> Baptiste discovered a rather nasty memory leak when using a bitstream
> filter with shared libraries.
> 
> In ffmpeg.c:write_frame() the output of bitstream filters is stored in
> an AVPacket, and its destruct function is set like this (line 417):
> 
>             new_pkt.destruct= av_destruct_packet;
> 
> Later on, in av_interleave_packet_per_dts(), AVPacket.destruct is
> compared against av_destruct_packet, like this (utils.c:2439):
> 
>         if(pkt->destruct == av_destruct_packet)

This seems like a misuse of pkt->destruct to me anyway, and for a simple
optimization in addition.
I am still not entirely certain I understood what this does, but I think
that a pkt->flag PKT_FREE_ON_DESTRUCT or some such would do.
This would still not fix applications outside of libavf without changing
their code as well, but IMO it would be more flexible and correct.
Apart from that: why is av_destruct_packet even part of the public API?
Is there actually any sane case where applications should use this
(except working around the fact that av_interleave_packet_per_dts
stupidly compares the destruct function instead of checking if pkt->data
was malloced or something, like proposed flag would allow)?
To me it seems that needing av_destruct_packet to be part of the public
API means out API is broken.

Greetings,
Reimar D?ffinger




More information about the ffmpeg-devel mailing list