diff --git a/libavcodec/speedhq.c b/libavcodec/speedhq.c index 128663ab75..229882761c 100644 --- a/libavcodec/speedhq.c +++ b/libavcodec/speedhq.c @@ -499,6 +499,8 @@ static int speedhq_decode_frame(AVCodecContext *avctx, if (buf_size < 4 || avctx->width < 8 || avctx->width % 8 != 0) return AVERROR_INVALIDDATA; + if (buf_size < avctx->width*avctx->height / 64 / 4) + return AVERROR_INVALIDDATA; quality = buf[0]; if (quality >= 100) {