harness: fix double free of streamed chunk text (chunk payloads are borrowed per letta.zig contract)

onProgressEvent freed .chunk text that handleLine also frees via defer —
double free corrupted the heap mid-turn; DebugAllocator caught it and
the reply tail was silently lost (delivered messages missing their final
characters while the CLI transcript held the full text).

👾 Generated with [Letta Code](https://letta.com)

Co-Authored-By: Letta Code <noreply@letta.com>
This commit is contained in:
pierreandLetta Code committed 2026-09-21 16:10:20 +03:00
1 parent 27327e94b0
commit 890970de81
1 file changed
+3 -1
+3 -1
View File
@@ -360,7 +360,9 @@ fn onProgressEvent(ctx: ?*anyopaque, ev: letta.Event) void {
p.ret(out); p.ret(out);
}, },
.chunk => |c| { .chunk => |c| {
defer p.alloc.free(c); // NOTE: chunk/step payloads are BORROWED — handleLine frees them
// via defer (same contract as the overlay UI). Freeing here too
// is a double free (heap corruption, silently lost reply tails).
_ = p.replyChunk(c, false); _ = p.replyChunk(c, false);
}, },
.step => {}, // legacy pre-formatted lines: superseded by structured .step => {}, // legacy pre-formatted lines: superseded by structured