fix(eficore): don't panic when filling a rectangle past the right edge

The slice start was after its end when the rectangle began beyond the
framebuffer width, which happens when the cursor is at the right edge.
This commit is contained in:
alex authored and Alex Zenla committed 2026-10-03 18:05:12 -07:00
1 parent 7d913b3ab4
commit de2df4a183
1 file changed
+4 -1
+4 -1
View File
@@ -46,8 +46,11 @@ impl Framebuffer {
pub fn fill_rect(&mut self, x: usize, y: usize, width: usize, height: usize, color: BltPixel) { pub fn fill_rect(&mut self, x: usize, y: usize, width: usize, height: usize, color: BltPixel) {
let end_x = x.saturating_add(width).min(self.width); let end_x = x.saturating_add(width).min(self.width);
let end_y = y.saturating_add(height).min(self.height); let end_y = y.saturating_add(height).min(self.height);
if x >= end_x {
return;
}
for row in y..end_y { for row in y..end_y {
// The row is in bounds, so its range is within the pixels. // The row and columns are in bounds, so its range is within the pixels.
self.pixels[row * self.width + x..row * self.width + end_x].fill(color); self.pixels[row * self.width + x..row * self.width + end_x].fill(color);
} }
} }