1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:17:34 +00:00

LibWeb: Implement subtraction using saturated_addition in CSSPixels

Fixes overflow bug found by UBSAN.
This commit is contained in:
Aliaksandr Kalenik 2023-07-25 14:46:44 +02:00 committed by Andreas Kling
parent 26c20e3da1
commit c431167736
2 changed files with 12 additions and 1 deletions

View file

@ -112,7 +112,7 @@ CSSPixels CSSPixels::operator+(CSSPixels const& other) const
CSSPixels CSSPixels::operator-(CSSPixels const& other) const
{
CSSPixels result;
result.set_raw_value(raw_value() - other.raw_value());
result.set_raw_value(saturated_addition(raw_value(), -other.raw_value()));
return result;
}