[FFmpeg-devel] [PATCH 3/8] Prevent svq3_get_ue_golomb() from returning a negative value.

Laurent Aimar fenrir at elivagar.org
Sat Sep 17 22:17:15 CEST 2011


On Sat, Sep 17, 2011 at 09:57:20PM +0200, Michael Niedermayer wrote:
> On Sat, Sep 17, 2011 at 09:12:06PM +0200, Laurent Aimar wrote:
> > On Sat, Sep 17, 2011 at 05:49:32PM +0200, Michael Niedermayer wrote:
> > > On Sat, Sep 17, 2011 at 04:56:31PM +0200, fenrir at elivagar.org wrote:
> > > > From: Laurent Aimar <fenrir at videolan.org>
> > > > 
> > > > ---
> > > >  libavcodec/golomb.h |    2 +-
> > > >  1 files changed, 1 insertions(+), 1 deletions(-)
> > > > 
> > > > diff --git a/libavcodec/golomb.h b/libavcodec/golomb.h
> > > > index 83d277f..58707ed 100644
> > > > --- a/libavcodec/golomb.h
> > > > +++ b/libavcodec/golomb.h
> > > > @@ -124,7 +124,7 @@ static inline int svq3_get_ue_golomb(GetBitContext *gb){
> > > >          }
> > > >  
> > > >          CLOSE_READER(re, gb);
> > > > -        return ret - 1;
> > > > +        return (ret - 1) & INT_MAX;
> > > 
> > > the individual uses of this function should check if the data is within
> > > the supported range.
> > > simply forcing it to be positiv is unlikely to be enough for all
> > > cases. Also it causes a tiny speedloss where such checks exists
> > > already
> >  Well, en general users of this function check for upper bound not lower bound
> > (which seems logical given the function names).
> >  Another way would be to make it return unsigned and check for every usage but
> > it's more work and I think more prone to breakage in the future.
> 
> theres no way around checking, ill commit checks in a moment

Thanks.

-- 
fenrir


More information about the ffmpeg-devel mailing list