diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index f8b398ffde..85bc447a81 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -824,6 +824,11 @@ static int decode_fctl_chunk(AVCodecContext *avctx, PNGDecContext *s, if (length != 26) return AVERROR_INVALIDDATA; + if (!(s->state & PNG_IHDR)) { + av_log(avctx, AV_LOG_ERROR, "fctl before IHDR\n"); + return AVERROR_INVALIDDATA; + } + s->last_w = s->cur_w; s->last_h = s->cur_h; s->last_x_offset = s->x_offset;