summaryrefslogtreecommitdiff
path: root/libavcodec/iff.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-11-29 17:57:05 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-05-02 02:50:34 +0200
commit9ae6f5ae92def1e1206f28ba823d0e3b3c222096 (patch)
tree0f1ab9bf37a693d82fbec07ff6770032303e0527 /libavcodec/iff.c
parent3d0559ee7d05e661a824c4af3ad9068fd4c7e0ac (diff)
downloadffmpeg-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.c7
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);