Message ID | 1570067596-19224-1-git-send-email-mypopydev@gmail.com |
---|---|
State | Accepted |
Commit | 9f353e376b161eb16a78fd7ad727c9513ac60d13 |
Headers | show |
On Thu, Oct 03, 2019 at 09:53:15AM +0800, Jun Zhao wrote: > From: Mengye Lv <mengyelv@tencent.com> > > When used ROUNDED_DIV(a,b), if a is unsigned integer zero, it's > will lead to an underflow issue(it called unsigned integer > wrapping). > > Fixes #8062 > > Signed-off-by: Mengye Lv <mengyelv@tencent.com> > Signed-off-by: Jun Zhao <barryjzhao@tencent.com> > --- > libavutil/common.h | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) LGTM thx [...]
On Sat, Oct 5, 2019 at 10:16 PM Michael Niedermayer <michael@niedermayer.cc> wrote: > > On Thu, Oct 03, 2019 at 09:53:15AM +0800, Jun Zhao wrote: > > From: Mengye Lv <mengyelv@tencent.com> > > > > When used ROUNDED_DIV(a,b), if a is unsigned integer zero, it's > > will lead to an underflow issue(it called unsigned integer > > wrapping). > > > > Fixes #8062 > > > > Signed-off-by: Mengye Lv <mengyelv@tencent.com> > > Signed-off-by: Jun Zhao <barryjzhao@tencent.com> > > --- > > libavutil/common.h | 2 +- > > 1 files changed, 1 insertions(+), 1 deletions(-) > > LGTM > > thx > Applied, Thx
diff --git a/libavutil/common.h b/libavutil/common.h index af35397..f09f0b4 100644 --- a/libavutil/common.h +++ b/libavutil/common.h @@ -53,7 +53,7 @@ //rounded division & shift #define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b)) /* assume b>0 */ -#define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b)) +#define ROUNDED_DIV(a,b) (((a)>=0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b)) /* Fast a/(1<<b) rounded toward +inf. Assume a>=0 and b>=0 */ #define AV_CEIL_RSHIFT(a,b) (!av_builtin_constant_p(b) ? -((-(a)) >> (b)) \ : ((a) + (1<<(b)) - 1) >> (b))