From 652f6f1deb00d83d7db3c09cbcd932e362cbbe2a Mon Sep 17 00:00:00 2001 From: Cheru Berhanu Date: Thu, 14 Aug 2025 17:51:45 -0700 Subject: [PATCH] terminal: fix use-after-free in exec This was only an issue on Linux, as MacOS' command is reallocated and rewritten. We hit this using embedded Ghostty w/o a login shell :p --- src/termio/Exec.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/termio/Exec.zig b/src/termio/Exec.zig index 15b6b8cd4..ec332afa1 100644 --- a/src/termio/Exec.zig +++ b/src/termio/Exec.zig @@ -1513,7 +1513,8 @@ fn execCommand( } return switch (command) { - .direct => |v| v, + // We need to clone the command since there's no guarantee the config remains valid. + .direct => |_| (try command.clone(alloc)).direct, .shell => |v| shell: { var args: std.ArrayList([:0]const u8) = try .initCapacity(alloc, 4);