Fix potential overflow in FramesAreSimilar

Bug: 496807858

Change-Id: Idc9af6f86a171322dd09e197dafbef59d5e4aa53
This commit is contained in:
Vincent Rabaud
2026-04-07 09:42:11 +02:00
parent 7ab12ced1e
commit 6a9eb44282
3 changed files with 10 additions and 5 deletions

View File

@@ -70,8 +70,10 @@ static int FramesAreSimilar(const uint8_t* const rgba1,
for (j = 0; j < height; ++j) {
for (i = 0; i < width; ++i) {
const int stride = width * 4;
const size_t offset = j * stride + i;
if (!PixelsAreSimilar(rgba1[offset], rgba2[offset], max_allowed_diff)) {
size_t offset_row, offset;
if (!CheckMultiplicationOverflow(j, stride, &offset_row) ||
!CheckAdditionOverflow(offset_row, i, &offset) ||
!PixelsAreSimilar(rgba1[offset], rgba2[offset], max_allowed_diff)) {
return 0;
}
}