Fix some potential integer overflows.

Bug: 483655390, 496629074, 496629076
Change-Id: Idba72361915f1ecf37532a306636011001c27755
This commit is contained in:
Vincent Rabaud
2026-04-03 14:04:12 +02:00
parent 0c9546f7ef
commit f51e813bf4
4 changed files with 168 additions and 43 deletions

View File

@@ -34,9 +34,15 @@ static int AdditionWillOverflow(int a, int b) {
}
static int FramesAreEqual(const uint8_t* const rgba1,
const uint8_t* const rgba2, int width, int height) {
const int stride = width * 4; // Always true for 'DecodedFrame.rgba'.
return !memcmp(rgba1, rgba2, stride * height);
const uint8_t* const rgba2, uint32_t width,
uint32_t height) {
// Always * 4 for 'DecodedFrame.rgba'.
const uint32_t stride = width * 4;
size_t size;
if (!CheckMultiplicationOverflow(stride, height, &size)) {
return 0;
}
return !memcmp(rgba1, rgba2, size);
}
static WEBP_INLINE int PixelsAreSimilar(uint32_t src, uint32_t dst,