History

avcodec/hq_hqa: Check size before initializing GetByteContext

Enables the compiler to optimize the buf_size assert in bytestream2_init() away.

Andreas Rheinhardt committed 1 year ago

Commit bf327ac1 parent 16943871 file · +2 −2Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/hq_hqa.c+2−2
@@ -326,11 +326,11 @@ static int hq_hqa_decode_frame(AVCodecContext *avctx, AVFrame *pic, · 325 unmodified lines
326 unsigned int data_size;326 unsigned int data_size;
327 int ret;327 int ret;
328 328
329 bytestream2_init(gbc, avpkt->data, avpkt->size);329 if (avpkt->size < 4 + 4) {
330 if (bytestream2_get_bytes_left(gbc) < 4 + 4) {
331 av_log(avctx, AV_LOG_ERROR, "Frame is too small (%d).\n", avpkt->size);330 av_log(avctx, AV_LOG_ERROR, "Frame is too small (%d).\n", avpkt->size);
332 return AVERROR_INVALIDDATA;331 return AVERROR_INVALIDDATA;
333 }332 }
333 bytestream2_init(gbc, avpkt->data, avpkt->size);
334 334
335 uint32_t info_tag = bytestream2_peek_le32u(gbc);335 uint32_t info_tag = bytestream2_peek_le32u(gbc);
336 if (info_tag == MKTAG('I', 'N', 'F', 'O')) {336 if (info_tag == MKTAG('I', 'N', 'F', 'O')) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t