1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

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 <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2025-04-09 22:10:16 +02:00
parent 16943876f8
commit bf327ac676

View File

@ -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')) {