From bf327ac6762dfbf17ce7c766bbcd3f86942769f6 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 9 Apr 2025 22:10:16 +0200 Subject: [PATCH] avcodec/hq_hqa: Check size before initializing GetByteContext Enables the compiler to optimize the buf_size assert in bytestream2_init() away. Signed-off-by: Andreas Rheinhardt --- libavcodec/hq_hqa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/hq_hqa.c b/libavcodec/hq_hqa.c index fd0c47cb28..c813b923b6 100644 --- a/libavcodec/hq_hqa.c +++ b/libavcodec/hq_hqa.c @@ -326,11 +326,11 @@ static int hq_hqa_decode_frame(AVCodecContext *avctx, AVFrame *pic, unsigned int data_size; int ret; - bytestream2_init(gbc, avpkt->data, avpkt->size); - if (bytestream2_get_bytes_left(gbc) < 4 + 4) { + if (avpkt->size < 4 + 4) { av_log(avctx, AV_LOG_ERROR, "Frame is too small (%d).\n", avpkt->size); return AVERROR_INVALIDDATA; } + bytestream2_init(gbc, avpkt->data, avpkt->size); uint32_t info_tag = bytestream2_peek_le32u(gbc); if (info_tag == MKTAG('I', 'N', 'F', 'O')) {