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
pull/8358/head
Cheru Berhanu 2025-08-14 17:51:45 -07:00
parent 0c722b0e3d
commit 652f6f1deb
1 changed files with 2 additions and 1 deletions

View File

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