From c117b1527e20ffad55135794f3c81f7f1aba8f11 Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Tue, 19 Dec 2023 15:07:07 -0800 Subject: [PATCH] Fixed integer overflow in Grid When no space is available for the first gutter when fractional widths are being used, there was a non-saturating subtraction that could underflow. --- src/widgets/grid.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/grid.rs b/src/widgets/grid.rs index dcecf60..30e658a 100644 --- a/src/widgets/grid.rs +++ b/src/widgets/grid.rs @@ -457,7 +457,7 @@ impl GridLayout { // Measure the weighted children within the remaining space if self.total_weights > 0 { if requires_gutter { - remaining -= gutter; + remaining = remaining.saturating_sub(gutter); } let space_per_weight = (remaining / self.total_weights).floor(); remaining = remaining.saturating_sub(space_per_weight * self.total_weights);