window(fill): fix bounds check

The bounds check should terminate at the window height.

Fixes: f7f4606f1d "window(fill): bounds check the memcpy op"
This commit is contained in:
Tim Culverhouse 2024-05-12 20:24:31 -05:00
parent f7f4606f1d
commit ca4346e35a

View file

@ -221,7 +221,7 @@ pub fn fill(self: Window, cell: Cell) void {
} else { } else {
// Non-contiguous. Iterate over rows an memset // Non-contiguous. Iterate over rows an memset
var row: usize = self.y_off; var row: usize = self.y_off;
const last_row = @min(self.height + self.y_off, self.screen.height - self.y_off); const last_row = @min(self.height + self.y_off, self.screen.height);
while (row < last_row) : (row += 1) { while (row < last_row) : (row += 1) {
const start = self.x_off + (row * self.screen.width); const start = self.x_off + (row * self.screen.width);
const end = @min(start + self.width, start + (self.screen.width - self.x_off)); const end = @min(start + self.width, start + (self.screen.width - self.x_off));