[FFmpeg-devel] [PATCH 6/9] avcodec/vc1_parser: Assert init_get_bits success

Michael Niedermayer michael at niedermayer.cc
Sat May 18 06:57:40 EEST 2024


The buffer used is a fixed size buffer from the context, it cannot be too large nor
can it be NULL

Helps: CID1441935 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavcodec/vc1_parser.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vc1_parser.c b/libavcodec/vc1_parser.c
index ec284dca009..a1557b1ec7e 100644
--- a/libavcodec/vc1_parser.c
+++ b/libavcodec/vc1_parser.c
@@ -66,7 +66,9 @@ static void vc1_extract_header(AVCodecParserContext *s, AVCodecContext *avctx,
     GetBitContext gb;
     int ret;
     vpc->v.s.avctx = avctx;
-    init_get_bits8(&gb, buf, buf_size);
+    ret = init_get_bits8(&gb, buf, buf_size);
+    av_assert1(ret >= 0);
+
     switch (vpc->prev_start_code) {
     case VC1_CODE_SEQHDR & 0xFF:
         ff_vc1_decode_sequence_header(avctx, &vpc->v, &gb);
-- 
2.45.1



More information about the ffmpeg-devel mailing list