[FFmpeg-devel] [PATCH 1/2] avdevice/avfoundation: fix memleak

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Tue Feb 8 15:05:44 EET 2022


Thilo Borgmann:
> Am 08.02.22 um 13:50 schrieb Andreas Rheinhardt:
>> Thilo Borgmann:
>>> Am 04.02.22 um 17:19 schrieb Zhao Zhili:
>>>> ---
>>>>    libavdevice/avfoundation.m | 10 ++++++----
>>>>    1 file changed, 6 insertions(+), 4 deletions(-)
>>>>
>>>> diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
>>>> index 0cd6e646d5..2078c4879c 100644
>>>> --- a/libavdevice/avfoundation.m
>>>> +++ b/libavdevice/avfoundation.m
>>>> @@ -106,6 +106,7 @@ typedef struct
>>>>        int             audio_device_index;
>>>>        int             audio_stream_index;
>>>>    +    char            *url;
>>>>        char            *video_filename;
>>>>        char            *audio_filename;
>>>>    @@ -299,6 +300,7 @@ static void destroy_context(AVFContext* ctx)
>>>>        ctx->avf_delegate    = NULL;
>>>>        ctx->avf_audio_delegate = NULL;
>>>>    +    av_freep(&ctx->url);
>>>>        av_freep(&ctx->audio_buffer);
>>>
>>> Why carry it in the context instead of adding the missing av_freep() in
>>> parse_device_name() ?
>>>
>>
>> Because video_filename and audio_filename point into it.
> 
> Wondering if we couldn't skip av_strdup() and operate on s->url directly
> then.
> 

This would trash s->url.

- Andreas


More information about the ffmpeg-devel mailing list