summaryrefslogtreecommitdiff
path: root/src/termio
diff options
context:
space:
mode:
authorCheru Berhanu <cheru@cheru.dev>2025-08-14 17:51:45 -0700
committerCheru Berhanu <cheru@cheru.dev>2025-08-22 15:22:54 -0700
commit652f6f1deb00d83d7db3c09cbcd932e362cbbe2a (patch)
treeee5061a7ffda8fdf14f7d2826f844a812af06d0d /src/termio
parent0c722b0e3df759febfc26f44b2381d47ca3cc770 (diff)
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
Diffstat (limited to 'src/termio')
-rw-r--r--src/termio/Exec.zig3
1 files changed, 2 insertions, 1 deletions
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);