diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-11-29 17:57:05 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-05-02 02:50:34 +0200 |
commit | 9ae6f5ae92def1e1206f28ba823d0e3b3c222096 (patch) | |
tree | 0f1ab9bf37a693d82fbec07ff6770032303e0527 /libavcodec/iff.c | |
parent | 3d0559ee7d05e661a824c4af3ad9068fd4c7e0ac (diff) | |
download | ffmpeg-9ae6f5ae92def1e1206f28ba823d0e3b3c222096.tar.gz |
avcodec/iff: Reorder checks to avoid unnecessary alloc+free
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/iff.c')
-rw-r--r-- | libavcodec/iff.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/libavcodec/iff.c b/libavcodec/iff.c index fe1baf3a0c..b4d7b4b31c 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -299,14 +299,13 @@ static int extract_header(AVCodecContext *const avctx, avctx->pix_fmt = AV_PIX_FMT_RGB32; av_freep(&s->mask_buf); av_freep(&s->mask_palbuf); - s->mask_buf = av_malloc((s->planesize * 32) + AV_INPUT_BUFFER_PADDING_SIZE); - if (!s->mask_buf) - return AVERROR(ENOMEM); if (s->bpp > 16) { av_log(avctx, AV_LOG_ERROR, "bpp %d too large for palette\n", s->bpp); - av_freep(&s->mask_buf); return AVERROR(ENOMEM); } + s->mask_buf = av_malloc((s->planesize * 32) + AV_INPUT_BUFFER_PADDING_SIZE); + if (!s->mask_buf) + return AVERROR(ENOMEM); s->mask_palbuf = av_malloc((2 << s->bpp) * sizeof(uint32_t) + AV_INPUT_BUFFER_PADDING_SIZE); if (!s->mask_palbuf) { av_freep(&s->mask_buf); |