diff mbox series

[FFmpeg-devel,088/134] avcodec/iff: Reorder checks to avoid unnecessary alloc+free

Message ID 20201130005454.110441-16-andreas.rheinhardt@gmail.com
State Accepted
Commit 9ae6f5ae92def1e1206f28ba823d0e3b3c222096
Headers show
Series [FFmpeg-devel,01/45] avcodec/a64multienc: Fix memleak upon init failure | expand

Checks

Context Check Description
andriy/x86 warning Failed to apply patch

Commit Message

Andreas Rheinhardt Nov. 30, 2020, 12:54 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/iff.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/iff.c b/libavcodec/iff.c
index 79f6215c77..21b69f6e94 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);