[FFmpeg-devel] [PATCH] Extradata memleak in libx264.c

Robert Swain robert.swain
Mon Oct 13 15:56:08 CEST 2008


2008/10/13 Benoit Fouet <ml_benoitfouet at purplelabs.com>:
> M?ns Rullg?rd wrote:
>> Benoit Fouet wrote:
>>
>>> Ralf Terdic wrote:
>>>
>>>> On Thursday 02 October 2008 15:22:09 Ralf Terdic wrote:
>>>>
>>>>
>>>>> On Thursday 02 October 2008 14:21:00 Benoit Fouet wrote:
>>>>>
>>>>>
>>>>>> Ralf Terdic wrote:
>>>>>>
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> In libx264.c, at the bottom of X264_init, avctx->extradata is
>>>>>>> allocated, but it's never freed. If the codec is repeatedly opened and
>>>>>>> closed, then the resulting leak is quite considerable.
>>>>>>>
>>>>>>> Please review and apply the attached fix.
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Ralf
>>>>>>>
>>>>>>> -----------------------------------------------------------------------
>>>>>>> -
>>>>>>>
>>>>>>> Index: libavcodec/libx264.c
>>>>>>> ===================================================================
>>>>>>> --- libavcodec/libx264.c  (revision 15509)
>>>>>>> +++ libavcodec/libx264.c  (working copy)
>>>>>>> @@ -122,6 +122,10 @@
>>>>>>>  static av_cold int
>>>>>>>  X264_close(AVCodecContext *avctx)
>>>>>>>  {
>>>>>>> +    if(avctx->flags & CODEC_FLAG_GLOBAL_HEADER){
>>>>>>> +        av_freep(&avctx->extradata);
>>>>>>> +    }
>>>>>>> +
>>>>>>>      X264Context *x4 = avctx->priv_data;
>>>>>>>
>>>>>>>
>>>>>> you should put the av_freep (without the if) below the declaration...
>>>>>>
>>>>>>
>>>>> Okay, thanks. See corrected patch.
>>>>>
>>>>>
>>>> Would anybody please apply this patch? This memleak is quite annoying.
>>>>
>>> M?ns ?
>>>
>>
>> Fine by me.
>
> Applied
>
>>   Am I still listed as maintainer for that file?
>
> yes, you are
>
>>   As I've said
>> before, anyone who actually uses it is welcome to take over.
>
> I guess Jason or Rob could take it over

I'd prefer that Jason look after it as he knows the goings on of x264
stuff better and more rapidly than I do these days. I mean, it is what
he does... :)

Jason?

Rob



More information about the ffmpeg-devel mailing list