[FFmpeg-cvslog] avcodec/hq_hqa: Check size before initializing GetByteContext
Andreas Rheinhardt
git at videolan.org
Sun Apr 13 10:01:15 EEST 2025
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Wed Apr 9 22:10:16 2025 +0200| [bf327ac6762dfbf17ce7c766bbcd3f86942769f6] | committer: Andreas Rheinhardt
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 at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bf327ac6762dfbf17ce7c766bbcd3f86942769f6
---
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')) {
More information about the ffmpeg-cvslog
mailing list