From f970fd9840369e69c695e3e8631ec5e91b5549fa Mon Sep 17 00:00:00 2001 From: Vishnu Tejas E Date: Tue, 7 Oct 2025 10:44:20 +0530 Subject: [PATCH] Fix integer overflows in the damage shaper --- src/backend/renderer/damage/shaper.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/renderer/damage/shaper.rs b/src/backend/renderer/damage/shaper.rs index c83ed03c626e..caff076e138a 100644 --- a/src/backend/renderer/damage/shaper.rs +++ b/src/backend/renderer/damage/shaper.rs @@ -65,7 +65,7 @@ impl DamageShaper { in_damage .iter() .fold((i32::MAX, i32::MAX, i32::MIN, i32::MIN, i32::MIN), |acc, rect| { - let area = rect.size.w * rect.size.h; + let area = rect.size.w.saturating_mul(rect.size.h); ( acc.0.min(rect.loc.x), acc.1.min(rect.loc.y), @@ -81,7 +81,7 @@ impl DamageShaper { let damage_bbox = Rectangle::::new((x_min, y_min).into(), (bbox_w, bbox_h).into()); // Damage the current bounding box when there's a damage rect covering near all the area. - if max_damage_area as f32 / (damage_bbox.size.w * damage_bbox.size.h) as f32 + if max_damage_area as f32 / (damage_bbox.size.w.saturating_mul(damage_bbox.size.h)) as f32 > MAX_DAMAGE_TO_DAMAGE_BBOX_RATIO { self.out_damage.push(damage_bbox);