]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/bink: Fix memleak upon init failure
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Fri, 4 Sep 2020 15:49:16 +0000 (17:49 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Fri, 4 Sep 2020 18:37:12 +0000 (20:37 +0200)
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.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavcodec/bink.c

index f251ab4017fd451292881cd3b0fd9263e13704d2..c7ef333bd422aaef5ca0c7e9e370de3f1fc0207e 100644 (file)
@@ -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,
 };