diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c index c8865d7c63..6ea64a8a3b 100644 --- a/libavcodec/mdec.c +++ b/libavcodec/mdec.c @@ -174,6 +174,9 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, int buf_size = avpkt->size; int ret; + if (a->mb_width * a->mb_height * 3 > buf_size) + return AVERROR_INVALIDDATA; + if ((ret = ff_thread_get_buffer(avctx, frame, 0)) < 0) return ret;