[FFmpeg-devel] [PATCH] free AVFormatContext::key

Måns Rullgård mans
Sat Sep 25 12:58:40 CEST 2010


Reimar D?ffinger <Reimar.Doeffinger at gmx.de> writes:

> On Sat, Sep 25, 2010 at 11:12:14AM +0100, M?ns Rullg?rd wrote:
>> Reimar D?ffinger <Reimar.Doeffinger at gmx.de> writes:
>> > this is malloc'd by the AVOptions, but never freed.
>> > The easiest solution is to free it manually, though we
>> > could probably add a AVOptions API that frees everything
>> > it has allocated...
>> > Index: ffmpeg.c
>> > ===================================================================
>> > --- ffmpeg.c    (revision 25163)
>> > +++ ffmpeg.c    (working copy)
>> > @@ -603,8 +603,10 @@
>> >          av_metadata_free(&s->metadata);
>> >          av_free(s);
>> >      }
>> > -    for(i=0;i<nb_input_files;i++)
>> > +    for(i=0;i<nb_input_files;i++) {
>> > +        av_freep(&input_files[i]->key);
>> >          av_close_input_file(input_files[i]);
>> > +    }
>> 
>> This is not the leak you are looking for.  That one was fixed in
>> r24899.
>
> Hm, I have some doubts that change is correct.
> For any application that does not use AVOptions to set it,
> ->key does not even have to be malloced (it could be a constant).
> Thus IMO it's wrong to try to free it in av_close_input_file.

Good point.  However, ffplay and friends also need to be fixed.  I
think the best solution is probably a common function (in cmdutils.c)
to do the cleanup.

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list