X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fhq_hqa.c;h=eec2e980b3a40aecd33db59b72955955683b9b76;hb=1e6cef686183288a50eb4e45265a3a7f7582b1b5;hp=f88ad7d5f5a32a2e06ffe8784c7670936b2f238f;hpb=52b44e9d15c0ee3c118ed68a0c2c737a9eb50ae9;p=ffmpeg diff --git a/libavcodec/hq_hqa.c b/libavcodec/hq_hqa.c index f88ad7d5f5a..eec2e980b3a 100644 --- a/libavcodec/hq_hqa.c +++ b/libavcodec/hq_hqa.c @@ -181,6 +181,9 @@ static int hqa_decode_mb(HQContext *c, AVFrame *pic, int qgroup, int flag = 0; int i, ret, cbp; + if (get_bits_left(gb) < 1) + return AVERROR_INVALIDDATA; + cbp = get_vlc2(gb, c->hqa_cbp_vlc.table, 5, 1); for (i = 0; i < 12; i++) @@ -245,13 +248,18 @@ static int hqa_decode_frame(HQContext *ctx, AVFrame *pic, size_t data_size) int width, height, quant; const uint8_t *src = ctx->gbc.buffer; + if (bytestream2_get_bytes_left(&ctx->gbc) < 8 + 4*(num_slices + 1)) + return AVERROR_INVALIDDATA; + width = bytestream2_get_be16(&ctx->gbc); height = bytestream2_get_be16(&ctx->gbc); + ret = ff_set_dimensions(ctx->avctx, width, height); + if (ret < 0) + return ret; + ctx->avctx->coded_width = FFALIGN(width, 16); ctx->avctx->coded_height = FFALIGN(height, 16); - ctx->avctx->width = width; - ctx->avctx->height = height; ctx->avctx->bits_per_raw_sample = 8; ctx->avctx->pix_fmt = AV_PIX_FMT_YUVA422P;