fix some 'unsigned integer overflow' warnings in ubsan

I couldn't find a safe way of fixing VP8GetSigned() so i just
used the big-hammer.

Change-Id: I1039bc00307d1c90c85909a458a4bc70670e48b7
This commit is contained in:
skal
2016-08-16 15:02:43 -07:00
committed by James Zern
parent 8a4ebc6ab0
commit 6ab496ed22
11 changed files with 56 additions and 42 deletions

View File

@ -342,14 +342,16 @@ static WEBP_INLINE void VP8LPrefixEncode(int distance, int* const code,
}
// Sum of each component, mod 256.
static WEBP_INLINE uint32_t VP8LAddPixels(uint32_t a, uint32_t b) {
static WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW WEBP_INLINE
uint32_t VP8LAddPixels(uint32_t a, uint32_t b) {
const uint32_t alpha_and_green = (a & 0xff00ff00u) + (b & 0xff00ff00u);
const uint32_t red_and_blue = (a & 0x00ff00ffu) + (b & 0x00ff00ffu);
return (alpha_and_green & 0xff00ff00u) | (red_and_blue & 0x00ff00ffu);
}
// Difference of each component, mod 256.
static WEBP_INLINE uint32_t VP8LSubPixels(uint32_t a, uint32_t b) {
static WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW WEBP_INLINE
uint32_t VP8LSubPixels(uint32_t a, uint32_t b) {
const uint32_t alpha_and_green =
0x00ff00ffu + (a & 0xff00ff00u) - (b & 0xff00ff00u);
const uint32_t red_and_blue =