From 00ff988a59b0874720121db7d980fb1a5f653fe4 Mon Sep 17 00:00:00 2001 From: James Zern Date: Mon, 8 Aug 2022 13:54:40 -0700 Subject: [PATCH] vp8l_enc,AddSingleSubGreen: clear int sanitizer warnings this localizes the conversion to int in the function; the parameter was previously changed in: 6ab496ed fix some 'unsigned integer overflow' warnings in ubsan implicit conversion from type 'uint32_t' (aka 'unsigned int') of value 2350919223 (32-bit, unsigned) to type 'int' changed the value to -1944048073 (32-bit, signed) Bug: b/229626362 Change-Id: I589eec11c0dabaeba99e153e705f956181c570d2 --- src/enc/vp8l_enc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/enc/vp8l_enc.c b/src/enc/vp8l_enc.c index 2b345df6..713adddf 100644 --- a/src/enc/vp8l_enc.c +++ b/src/enc/vp8l_enc.c @@ -361,10 +361,11 @@ typedef enum { kHistoTotal // Must be last. } HistoIx; -static void AddSingleSubGreen(int p, uint32_t* const r, uint32_t* const b) { - const int green = p >> 8; // The upper bits are masked away later. - ++r[((p >> 16) - green) & 0xff]; - ++b[((p >> 0) - green) & 0xff]; +static void AddSingleSubGreen(uint32_t p, + uint32_t* const r, uint32_t* const b) { + const int green = (int)p >> 8; // The upper bits are masked away later. + ++r[(((int)p >> 16) - green) & 0xff]; + ++b[(((int)p >> 0) - green) & 0xff]; } static void AddSingle(uint32_t p,