[FFmpeg-devel] [PATCH]lavc/opusdec: Fix a memleak when reading invalid files

James Almer jamrial at gmail.com
Fri Nov 20 02:59:34 CET 2015


On 11/19/2015 10:05 PM, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch fixes a memleak with the sample from bug 909.
> 
> Please comment, Carl Eugen
> 
> 
> patchopus.diff
> 
> 
> diff --git a/libavcodec/opusdec.c b/libavcodec/opusdec.c
> index 31871e9..6102591 100644
> --- a/libavcodec/opusdec.c
> +++ b/libavcodec/opusdec.c
> @@ -671,8 +671,10 @@ static av_cold int opus_decode_init(AVCodecContext *avctx)
>  
>      /* find out the channel configuration */
>      ret = ff_opus_parse_extradata(avctx, c);
> -    if (ret < 0)
> +    if (ret < 0) {
> +        av_freep(&c->fdsp);
>          return ret;

ff_opus_parse_extradata() can allocate s->channel_maps, so i think it should
also be freed here.

LGTM aside from that.

> +    }
>  
>      /* allocate and init each independent decoder */
>      c->streams = av_mallocz_array(c->nb_streams, sizeof(*c->streams));



More information about the ffmpeg-devel mailing list