]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/iff.c
Merge commit 'ffb0af7f17eb0da86e9b140e86a1404d3c6c9e79'
[ffmpeg] / libavcodec / iff.c
index a4b90fa4a3e61850c9262ab41701405d336a4cd0..5d69539171a096b088de89f698513af6d8a44116 100644 (file)
@@ -318,6 +318,16 @@ static int extract_header(AVCodecContext *const avctx,
     return 0;
 }
 
+static av_cold int decode_end(AVCodecContext *avctx)
+{
+    IffContext *s = avctx->priv_data;
+    av_frame_free(&s->frame);
+    av_freep(&s->planebuf);
+    av_freep(&s->ham_buf);
+    av_freep(&s->ham_palbuf);
+    return 0;
+}
+
 static av_cold int decode_init(AVCodecContext *avctx)
 {
     IffContext *s = avctx->priv_data;
@@ -360,8 +370,10 @@ static av_cold int decode_init(AVCodecContext *avctx)
 
     s->bpp = avctx->bits_per_coded_sample;
     s->frame = av_frame_alloc();
-    if (!s->frame)
+    if (!s->frame) {
+        decode_end(avctx);
         return AVERROR(ENOMEM);
+    }
 
     if ((err = extract_header(avctx, NULL)) < 0)
         return err;
@@ -858,16 +870,6 @@ static int decode_frame(AVCodecContext *avctx,
     return buf_size;
 }
 
-static av_cold int decode_end(AVCodecContext *avctx)
-{
-    IffContext *s = avctx->priv_data;
-    av_frame_free(&s->frame);
-    av_freep(&s->planebuf);
-    av_freep(&s->ham_buf);
-    av_freep(&s->ham_palbuf);
-    return 0;
-}
-
 #if CONFIG_IFF_ILBM_DECODER
 AVCodec ff_iff_ilbm_decoder = {
     .name           = "iff",