[FFmpeg-devel] [PATCH] libavformat/mov.c memleak bugfix

Zdenek Kabelac zdenek.kabelac
Sat Jan 26 12:42:08 CET 2008


2008/1/26, M?ns Rullg?rd <mans at mansr.com>:
> Baptiste Coudurier <baptiste.coudurier at smartjog.com> writes:
>
> > Zdenek Kabelac wrote:
> >> 2008/1/26, M?ns Rullg?rd <mans at mansr.com>:
> >>> "Zdenek Kabelac" <zdenek.kabelac at gmail.com> writes:
> >>>
> > So far av_write_trailer free priv_data for AVStream, I thought it was
> > more consistent to do the same for demuxers.
> >
> > If people thinks every demuxer should free priv_data, Im ok, that would
> > just duplicate some code.
>
> As long as the value is either NULL or a pointer from av_malloc(),
> freeing in a common place is safe.  The trouble is if some demuxer
> were to store a pointer to static data, or anything else that isn't
> valid for av_free().  Apparently that is not being done, though.
>
> I realise that I am probably backtracking on what I said earlier.

Ok - to move forward - here is plain grep through libavformat:

$ grep priv_data *.c  | grep free
asf.c:            av_free(st->priv_data);
asf.c:        av_free(st->priv_data);
ffm.c:        av_freep(&st->priv_data);
ffm.c:            av_freep(&st->priv_data);
ffm.c:        av_freep(&st->priv_data);
mpegenc.c:        av_free(ctx->streams[i]->priv_data);
mpegtsenc.c:        av_free(st->priv_data);
oggenc.c:                av_freep(&st->priv_data);
oggenc.c:                av_freep(&st->priv_data);
oggenc.c:        av_freep(&st->priv_data);
utils.c:        av_freep(&ic->priv_data);
utils.c:        av_free(st->priv_data);
utils.c:    av_freep(&s->priv_data);
utils.c:        av_freep(&s->streams[i]->priv_data);
utils.c:    av_freep(&s->priv_data);


So - asf seem to free pointer but doens't use av_freep, mpegenc.c
would have similar problem. Everything else looks like it shouldn't do
any harm to release data in close_stream (and then these free calls
could be probbly removed).

So - I think - no we have

1.) 1line patch to mov.c (but eventually their might be missing in other codecs)

2.) 1line patch to util.c - but some other muxers must be checked/repaired.

Which version is preffered - and who will do it ;) ?

Zdenek




More information about the ffmpeg-devel mailing list