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

Michael Niedermayer michael at niedermayer.cc
Fri May 3 00:32:21 EEST 2024


On Thu, May 02, 2024 at 10:25:24AM +0200, Andreas Rheinhardt wrote:
> 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).

will apply with these changes

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Observe your enemies, for they first find out your faults. -- Antisthenes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20240502/d0cc05e8/attachment.sig>


More information about the ffmpeg-devel mailing list