- commit
- 8560c39
- parent
- 10c30ff
- author
- Eric Bower
- date
- 2025-10-13 11:18:46 -0400 EDT
fix(attach): use-after-free bug
1 files changed,
+5,
-5
+5,
-5
1@@ -104,10 +104,8 @@ pub fn main(config: config_mod.Config, iter: *std.process.ArgIterator) !void {
2 .loop = &loop,
3 .session_name = session_name,
4 .config = config,
5- .frame_buffer = std.ArrayList(u8){},
6+ .frame_buffer = std.ArrayList(u8).initCapacity(allocator, 4096) catch unreachable,
7 };
8- ctx.frame_buffer = std.ArrayList(u8).initCapacity(allocator, 4096) catch unreachable;
9- defer ctx.frame_buffer.deinit(allocator);
10
11 // Get terminal size
12 var ws: c.struct_winsize = undefined;
13@@ -635,8 +633,10 @@ fn closeCallback(
14 } else |err| {
15 std.debug.print("close failed: {s}\n", .{@errorName(err)});
16 }
17- ctx.allocator.destroy(completion);
18- ctx.allocator.destroy(ctx);
19+ const allocator = ctx.allocator;
20+ ctx.frame_buffer.deinit(allocator);
21+ allocator.destroy(completion);
22+ allocator.destroy(ctx);
23 loop.stop();
24 return .disarm;
25 }