From ec09912fa80f9581579d0f86f109f6703484f46e Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Fri, 2 Aug 2024 07:28:06 -0500 Subject: [PATCH] window(fill): bounds check end condition for fill Fixes #65 --- src/Window.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Window.zig b/src/Window.zig index 4181670..a19e954 100644 --- a/src/Window.zig +++ b/src/Window.zig @@ -218,7 +218,7 @@ pub fn fill(self: Window, cell: Cell) void { if (self.x_off == 0 and self.width == self.screen.width) { // we have a full width window, therefore contiguous memory. const start = self.y_off * self.width; - const end = start + (self.height * self.width); + const end = @min(start + (self.height * self.width), self.screen.buf.len); @memset(self.screen.buf[start..end], cell); } else { // Non-contiguous. Iterate over rows an memset