diff mbox series

[FFmpeg-devel,1/5] avcodec/rv34: assert that size is not 0 in rv34_gen_vlc_ext()

Message ID 20240516231932.6950-1-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,1/5] avcodec/rv34: assert that size is not 0 in rv34_gen_vlc_ext() | 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

Michael Niedermayer May 16, 2024, 11:19 p.m. UTC
Helps: CID1548380 Uninitialized scalar variable

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/rv34.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Andreas Rheinhardt May 19, 2024, 4:05 p.m. UTC | #1
Michael Niedermayer:
> Helps: CID1548380 Uninitialized scalar variable
> 
> Sponsored-by: Sovereign Tech Fund
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/rv34.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
> index 23a570bb807..4ce0cc58d05 100644
> --- a/libavcodec/rv34.c
> +++ b/libavcodec/rv34.c
> @@ -98,6 +98,8 @@ static av_cold void rv34_gen_vlc_ext(const uint8_t *bits, int size, VLC *vlc,
>      uint16_t cw[MAX_VLC_SIZE];
>      int maxbits;
>  
> +    av_assert0(size > 0);
> +
>      for (int i = 0; i < size; i++)
>          counts[bits[i]]++;
>  

An av_assert0 just because of Coverity? Why not av_assert1?

- Andreas
Michael Niedermayer May 19, 2024, 7:48 p.m. UTC | #2
On Sun, May 19, 2024 at 06:05:20PM +0200, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Helps: CID1548380 Uninitialized scalar variable
> > 
> > Sponsored-by: Sovereign Tech Fund
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavcodec/rv34.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
> > index 23a570bb807..4ce0cc58d05 100644
> > --- a/libavcodec/rv34.c
> > +++ b/libavcodec/rv34.c
> > @@ -98,6 +98,8 @@ static av_cold void rv34_gen_vlc_ext(const uint8_t *bits, int size, VLC *vlc,
> >      uint16_t cw[MAX_VLC_SIZE];
> >      int maxbits;
> >  
> > +    av_assert0(size > 0);
> > +
> >      for (int i = 0; i < size; i++)
> >          counts[bits[i]]++;
> >  
> 
> An av_assert0 just because of Coverity? Why not av_assert1?

the function is av_cold, so it doesnt really matter i think
but changed to av_assert1 locally

thx

[...]
Michael Niedermayer June 2, 2024, 7:14 p.m. UTC | #3
On Fri, May 17, 2024 at 01:19:28AM +0200, Michael Niedermayer wrote:
> Helps: CID1548380 Uninitialized scalar variable
> 
> Sponsored-by: Sovereign Tech Fund
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/rv34.c | 2 ++
>  1 file changed, 2 insertions(+)

will apply remaining patches

[...]
diff mbox series

Patch

diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index 23a570bb807..4ce0cc58d05 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -98,6 +98,8 @@  static av_cold void rv34_gen_vlc_ext(const uint8_t *bits, int size, VLC *vlc,
     uint16_t cw[MAX_VLC_SIZE];
     int maxbits;
 
+    av_assert0(size > 0);
+
     for (int i = 0; i < size; i++)
         counts[bits[i]]++;