[FFmpeg-devel] [PATCH] avformat/mov: fix memleak

Dave Rice dave at dericed.com
Mon Jun 29 00:11:55 EEST 2020


Hi Andreas,

> On Jun 27, 2020, at 5:09 PM, Andreas Rheinhardt <andreas.rheinhardt at gmail.com> wrote:
> 
> Zhao Zhili:
>> Remove the check on dv_demux since dv_fctx will leak if allocate
>> dv_demux failed.
>> ---
>> libavformat/mov.c | 7 +++----
>> 1 file changed, 3 insertions(+), 4 deletions(-)
>> 
>> diff --git a/libavformat/mov.c b/libavformat/mov.c
>> index adc52de947..f179b6efdd 100644
>> --- a/libavformat/mov.c
>> +++ b/libavformat/mov.c
>> @@ -7357,10 +7357,9 @@ static int mov_read_close(AVFormatContext *s)
>>         av_freep(&sc->coll);
>>     }
>> 
>> -    if (mov->dv_demux) {
>> -        avformat_free_context(mov->dv_fctx);
>> -        mov->dv_fctx = NULL;
>> -    }
>> +    av_freep(&mov->dv_demux);
>> +    avformat_free_context(mov->dv_fctx);
>> +    mov->dv_fctx = NULL;
>> 
>>     if (mov->meta_keys) {
>>         for (i = 1; i < mov->meta_keys_count; i++) {
>> 
> Do you have a sample for this? I am asking because there are more
> memleaks related to dv audio and I have a patch [1] for them, but I
> never found any sample for dv in mov/mp4, so it was never applied.

I’m working with a lot of DV lately. Could you clarify what type of sample that you are looking for?

> If I am not mistaken, then you are not only fixing a leak of dv_fctx in
> case allocation of dv_demux failed; you are also fixing a leak of
> dv_demux itself in the ordinary case where it could be successfully
> allocated. This should be reflected in the commit message.
> 
> - Andreas
> 
> [1]:
> https://patchwork.ffmpeg.org/project/ffmpeg/patch/20190916155502.17579-3-andreas.rheinhardt@gmail.com/
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".



More information about the ffmpeg-devel mailing list