diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 9634858e1f..cc2795e5c5 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -1242,7 +1242,7 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s, case MKTAG('f', 'd', 'A', 'T'): if (!CONFIG_APNG_DECODER || avctx->codec_id != AV_CODEC_ID_APNG) goto skip_tag; - if (!decode_next_dat) { + if (!decode_next_dat || length < 4) { ret = AVERROR_INVALIDDATA; goto fail; }