[FFmpeg-devel] [PATCH 4/7] avcodec/avs2_parser: Assert init_get_bits8() success with const size 15

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Thu May 2 11:25:24 EEST 2024


Michael Niedermayer:
> Fixes: CID1506708 Unchecked return value
> 
> Sponsored-by: Sovereign Tech Fund
> Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> ---
>  libavcodec/avs2_parser.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/avs2_parser.c b/libavcodec/avs2_parser.c
> index 200134f91db..8d4bc3cee0d 100644
> --- a/libavcodec/avs2_parser.c
> +++ b/libavcodec/avs2_parser.c
> @@ -72,13 +72,15 @@ static void parse_avs2_seq_header(AVCodecParserContext *s, const uint8_t *buf,
>      unsigned aspect_ratio;
>      unsigned frame_rate_code;
>      int low_delay;
> +    int ret;
>      // update buf_size_min if parse more deeper
>      const int buf_size_min = 15;
>  
>      if (buf_size < buf_size_min)
>          return;
>  
> -    init_get_bits8(&gb, buf, buf_size_min);
> +    ret = init_get_bits8(&gb, buf, buf_size_min);
> +    av_assert2(ret >= 0);
>  
>      s->key_frame = 1;
>      s->pict_type = AV_PICTURE_TYPE_I;

Code like this may trigger set-but-unused variable warnings when
ASSERT_LEVEL is <= 1. Add av_unused to ret to fix this.
Apart from that, it should be av_assert1 (this is not hot).

- Andreas



More information about the ffmpeg-devel mailing list