diff --git a/src/termio/shell_integration.zig b/src/termio/shell_integration.zig index 128b345ea..71492230e 100644 --- a/src/termio/shell_integration.zig +++ b/src/termio/shell_integration.zig @@ -353,7 +353,11 @@ fn setupBash( ); try env.put("ENV", integ_dir); - return .{ .shell = try cmd.toOwnedSlice() }; + // Get the command string from the builder, then copy it to the arena + // allocator. The stackFallback allocator's memory becomes invalid after + // this function returns, so we must copy to the arena. + const cmd_str = try cmd.toOwnedSlice(); + return .{ .shell = try alloc.dupeZ(u8, cmd_str) }; } test "bash" {