diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-05 01:16:27 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 01:16:28 -0300 |
| commit | adc8a50289f17ba15867f6d8e45844f57ee1aaa8 (patch) | |
| tree | 9e0c82a44c7d1a149359cb174e429ceaccae959f /src/ninep | |
| parent | 7d359addc420eca66bd1583d8fd8d6a104986a03 (diff) | |
| download | pardes-adc8a50289f17ba15867f6d8e45844f57ee1aaa8.tar.gz pardes-adc8a50289f17ba15867f6d8e45844f57ee1aaa8.zip | |
ninep tree: a ctl line's bytes are the gpa's until its write is answered, where they were the step's scratch: a `size` line resizes and syncs (a step, which resets the scratch under it) and then quotes its value in a refusal, so the refusal read freed memory; the base kept the arena's buffer by luck, and the merged line's bigger steps freed it (a segfault in the behaviour test 'size sets the screen of a session no frontend is attached to')
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/ninep')
| -rw-r--r-- | src/ninep/tree.zig | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig index b55065fd..53bec357 100644 --- a/src/ninep/tree.zig +++ b/src/ninep/tree.zig @@ -1295,7 +1295,11 @@ fn writeLines(p: *Pardes, req: Req, target: Target) Reply { } o.named = true; } - const whole = p.scratch.allocator().dupe(u8, o.pending.items[0..end]) catch return Reply.fail(req.tag, E.NOMEM); + // The line outlives any step its command runs (a `size` resizes and + // syncs, then quotes its value in a refusal): the step's scratch is + // reset under it, so the line is the gpa's until the write is answered. + const whole = p.gpa.dupe(u8, o.pending.items[0..end]) catch return Reply.fail(req.tag, E.NOMEM); + defer p.gpa.free(whole); const rest = o.pending.items.len - end; std.mem.copyForwards(u8, o.pending.items[0..rest], o.pending.items[end..]); o.pending.shrinkRetainingCapacity(rest); |
