From f1473a146475e697953277b82c65db658fc8c63d Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Tue, 10 Sep 2024 17:22:29 -0500 Subject: [PATCH] fix: Surface.selectionString should return sentinel slice The underlying API call returns a sentinel slice so selectionString should do the same or there are problems later trying to free the allocated memory. --- src/Surface.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Surface.zig b/src/Surface.zig index c4c30f675..d59793881 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -932,7 +932,7 @@ pub fn hasSelection(self: *const Surface) bool { } /// Returns the selected text. This is allocated. -pub fn selectionString(self: *Surface, alloc: Allocator) !?[]const u8 { +pub fn selectionString(self: *Surface, alloc: Allocator) !?[:0]const u8 { self.renderer_state.mutex.lock(); defer self.renderer_state.mutex.unlock(); const sel = self.io.terminal.screen.selection orelse return null;