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

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Mon Jun 29 23:30:37 EEST 2020


Dave Rice:
> 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?
> 

I was looking for samples with data format/Fourcc vdva or dvca to
trigger the codepath introduced in
b60c04547c9b59685d4cdc09d85efcf750978f60. But I have now found one*, so
I don't need your help any more. But thanks for the offer.

- Andreas

*: https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4671/dir1.tar.bz2
contains such samples (set the enable_drefs option to 1 for it to work).
Found via https://github.com/bcoudurier/FFmbc/pull/3 which I strangely
didn't find when searching for this last year.


More information about the ffmpeg-devel mailing list