1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:27:35 +00:00

LibWeb: Use i64 for intermediate value in CSSPixels multiplication

Reduce the chance of overflow due to fixed point denominator being
squared when multiplying the raw values, before adjusting the final
value back.
This commit is contained in:
Andi Gallo 2023-08-04 10:33:30 +00:00 committed by Alexander Kalenik
parent bed5a752df
commit e9ad8d5e4f
2 changed files with 9 additions and 1 deletions

View file

@ -87,4 +87,12 @@ TEST_CASE(saturated_subtraction)
EXPECT_EQ(value - -1, CSSPixels(INFINITY));
}
TEST_CASE(multiplication_uses_i64_for_raw_values)
{
CSSPixels a(1200);
CSSPixels b(647);
CSSPixels c = a * b;
EXPECT_EQ(c, CSSPixels(776400));
}
}