From 9d26ab2dc822ce20c399921ec82f4b0151f4c297 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 6 Aug 2022 15:44:20 -0700 Subject: [PATCH] memset zero values when resizing a screen Zig safety checks save us! It was setting undefined values to `0xAA` and we caught that in a crash. We need to zero this memory. Practically this happened when `cat`-ing a large file, then attempting to select and copy any blank trailing space. --- src/terminal/Screen.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/src/terminal/Screen.zig b/src/terminal/Screen.zig index 6d9f7ef2b..e6460bf81 100644 --- a/src/terminal/Screen.zig +++ b/src/terminal/Screen.zig @@ -361,6 +361,7 @@ pub fn resize(self: *Screen, alloc: Allocator, rows: usize, cols: usize) !void { // Reallocate the storage self.storage = try alloc.alloc(Cell, (rows + self.max_scrollback) * cols); + std.mem.set(Cell, self.storage, .{ .char = 0 }); self.top = 0; self.bottom = rows; self.rows = rows;