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.
This commit is contained in:
Mitchell Hashimoto
2022-08-06 15:44:20 -07:00
parent 80719d1467
commit 9d26ab2dc8

View File

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