mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-02 03:06:28 +02:00
avcodec/iff: Reorder checks to avoid unnecessary alloc+free
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
parent
3d0559ee7d
commit
9ae6f5ae92
@ -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);
|
||||
if (s->bpp > 16) {
|
||||
av_log(avctx, AV_LOG_ERROR, "bpp %d too large for palette\n", s->bpp);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
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_palbuf = av_malloc((2 << s->bpp) * sizeof(uint32_t) + AV_INPUT_BUFFER_PADDING_SIZE);
|
||||
if (!s->mask_palbuf) {
|
||||
av_freep(&s->mask_buf);
|
||||
|
Loading…
Reference in New Issue
Block a user