From a387e680ed440fc435b650386c503be4801fdf7d Mon Sep 17 00:00:00 2001 From: Qwerasd Date: Wed, 25 Dec 2024 20:06:48 -0500 Subject: [PATCH] test: add additional checks to scroll above cross-page test Reveals a memory corruption issue caused by the direct assignment of `cursor.page_pin` instead of using the `cursorChangePin` method. --- src/terminal/Screen.zig | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/terminal/Screen.zig b/src/terminal/Screen.zig index 97a1f56dd..52fba95ef 100644 --- a/src/terminal/Screen.zig +++ b/src/terminal/Screen.zig @@ -4477,6 +4477,15 @@ test "Screen: scroll above same page but cursor on previous page last row" { try testing.expect(!s.pages.isDirty(.{ .active = .{ .x = 0, .y = 0 } })); try testing.expect(s.pages.isDirty(.{ .active = .{ .x = 0, .y = 1 } })); try testing.expect(s.pages.isDirty(.{ .active = .{ .x = 0, .y = 2 } })); + + // Attempt to clear the style from the cursor and + // then assert the integrity of both of our pages. + // + // This catches a case of memory corruption where the cursor + // is moved between pages without accounting for style refs. + try s.setAttribute(.{ .reset_bg = {} }); + s.pages.pages.first.?.data.assertIntegrity(); + s.pages.pages.last.?.data.assertIntegrity(); } test "Screen: scroll above creates new page" {