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.
This commit is contained in:
Jonathan Johnson 2023-12-19 15:07:07 -08:00
parent a79d2f7d58
commit c117b1527e
No known key found for this signature in database
GPG key ID: A66D6A34D6620579

View file

@ -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);