[FFmpeg-devel] bink: fix leaking last frame on error

Submitted by Andreas Cadhalpun on Feb. 16, 2017, 12:26 a.m.

Details

Message ID f6e30901-775c-f3ca-dc82-8d1a4023bd44@googlemail.com
State New
Headers show

Commit Message

Andreas Cadhalpun Feb. 16, 2017, 12:26 a.m.
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
---
 libavcodec/bink.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/libavcodec/bink.c b/libavcodec/bink.c
index cc55870114..91004a6ae5 100644
--- a/libavcodec/bink.c
+++ b/libavcodec/bink.c
@@ -1299,10 +1299,6 @@  static av_cold int decode_init(AVCodecContext *avctx)
     }
     c->avctx = avctx;
 
-    c->last = av_frame_alloc();
-    if (!c->last)
-        return AVERROR(ENOMEM);
-
     if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0)
         return ret;
 
@@ -1317,6 +1313,10 @@  static av_cold int decode_init(AVCodecContext *avctx)
         return ret;
     }
 
+    c->last = av_frame_alloc();
+    if (!c->last)
+        return AVERROR(ENOMEM);
+
     if (c->version == 'b') {
         if (!binkb_initialised) {
             binkb_calc_quant();