X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fiff.c;h=5d69539171a096b088de89f698513af6d8a44116;hb=61f40fbb528d6e25b78ce673826388e3493155c4;hp=a4b90fa4a3e61850c9262ab41701405d336a4cd0;hpb=6a7de2361b94cef914f397314103c67165bdff53;p=ffmpeg diff --git a/libavcodec/iff.c b/libavcodec/iff.c index a4b90fa4a3e..5d69539171a 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -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",