summaryrefslogtreecommitdiff
path: root/src/ninep
diff options
context:
space:
mode:
Diffstat (limited to 'src/ninep')
-rw-r--r--src/ninep/tree.zig6
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);