diff mbox series

[FFmpeg-devel] avcodec/vc1_parser: Check init_get_bits8()

Message ID AS8P250MB074424B21169346A62F9A33F8FEE2@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit a7e506fcd8442ee432ae1450ccc4ce212b5c2e1e
Headers show
Series [FFmpeg-devel] avcodec/vc1_parser: Check init_get_bits8() | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt May 17, 2024, 8:16 p.m. UTC
Addresses Coverity issue #1441935.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/vc1_parser.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer May 18, 2024, 7:30 p.m. UTC | #1
On Fri, May 17, 2024 at 10:16:27PM +0200, Andreas Rheinhardt wrote:
> Addresses Coverity issue #1441935.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/vc1_parser.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

seems i didnt see this one, as i send a patch for this too
anyway your LGTM

thx

[...]
diff mbox series

Patch

diff --git a/libavcodec/vc1_parser.c b/libavcodec/vc1_parser.c
index ec284dca00..a536a7bcf8 100644
--- a/libavcodec/vc1_parser.c
+++ b/libavcodec/vc1_parser.c
@@ -26,6 +26,7 @@ 
  */
 
 #include "libavutil/attributes.h"
+#include "libavutil/avassert.h"
 #include "parser.h"
 #include "vc1.h"
 #include "get_bits.h"
@@ -66,7 +67,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); // buf_size is bounded by UNESCAPED_THRESHOLD
+
     switch (vpc->prev_start_code) {
     case VC1_CODE_SEQHDR & 0xFF:
         ff_vc1_decode_sequence_header(avctx, &vpc->v, &gb);