[FFmpeg-devel] [PATCH 1/6] avcodec/bink: Fix memleak upon init failure

Paul B Mahol onemda at gmail.com
Fri Sep 4 20:40:28 EEST 2020


On 9/4/20, Andreas Rheinhardt <andreas.rheinhardt at gmail.com> wrote:
> The init function first allocates an AVFrame and then some buffers; if
> one of the buffers couldn't be allocated, the AVFrame leaks. Solve this
> by setting the FF_CODEC_CAP_INIT_CLEANUP flag.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> ---
>  libavcodec/bink.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>

LGTM

> diff --git a/libavcodec/bink.c b/libavcodec/bink.c
> index f251ab4017..c7ef333bd4 100644
> --- a/libavcodec/bink.c
> +++ b/libavcodec/bink.c
> @@ -1381,10 +1381,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
>      ff_hpeldsp_init(&c->hdsp, avctx->flags);
>      ff_binkdsp_init(&c->binkdsp);
>
> -    if ((ret = init_bundles(c)) < 0) {
> -        free_bundles(c);
> +    if ((ret = init_bundles(c)) < 0)
>          return ret;
> -    }
>
>      if (c->version == 'b') {
>          if (!binkb_initialised) {
> @@ -1424,4 +1422,5 @@ AVCodec ff_bink_decoder = {
>      .decode         = decode_frame,
>      .flush          = flush,
>      .capabilities   = AV_CODEC_CAP_DR1,
> +    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
>  };
> --
> 2.20.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-devel mailing list