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

Benoit Fouet ml_benoitfouet
Thu Oct 2 14:21:00 CEST 2008


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...

-- 
Benoit Fouet
Purple Labs S.A.
www.purplelabs.com





More information about the ffmpeg-devel mailing list