[FFmpeg-devel] [PATCH] fix memleak in ogg demuxer
Reimar Döffinger
Reimar.Doeffinger
Fri Jan 21 19:03:41 CET 2011
On Thu, Jan 20, 2011 at 10:50:02PM +0000, M?ns Rullg?rd wrote:
> Reimar D?ffinger <Reimar.Doeffinger at gmx.de> writes:
>
> > Hello,
> > the sample in http://bugzilla.mplayerhq.hu/show_bug.cgi?id=1148 cause a
> > memleak in the ogg demuxer.
> > That is because oggparsevorbis caches a few packets, and if we close
> > the demuxer before reaching the end of the header packets they will
> > never be freed.
> > Patch below that adds and uses a close function for the codec-specific
> > ogg header parser fixes it.
> > I have not check the others whether they have a similar issue.
> > Index: ffmpeg/libavformat/oggdec.c
> > ===================================================================
> > --- ffmpeg/libavformat/oggdec.c (revision 25928)
> > +++ ffmpeg/libavformat/oggdec.c (working copy)
> > @@ -588,6 +588,8 @@
> >
> > for (i = 0; i < ogg->nstreams; i++){
> > av_free (ogg->streams[i].buf);
> > + if (ogg->streams[i].codec && ogg->streams[i].codec->close)
> > + ogg->streams[i].codec->close(s, i);
>
> Why not pass the priv pointer directly here,
Mostly because like this it matches the header() function that
allocates it so API wise it also work if deallocation needs
something from the context.
I was also thinking about making the close function export everything
it has as extradata, but that doesn't make sense as long as it is
only called from ogg_read_close so I now have some doubts about it.
More information about the ffmpeg-devel
mailing list