From eae0f0318a22417edd4a4ae78bae13fc5fca5e39 Mon Sep 17 00:00:00 2001 From: Ciro Spaciari Date: Fri, 15 Mar 2024 17:00:19 -0300 Subject: [PATCH] fix ref counting onReaderDone (#9443) --- src/shell/subproc.zig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/shell/subproc.zig b/src/shell/subproc.zig index d910d9332a..28f068d3a0 100644 --- a/src/shell/subproc.zig +++ b/src/shell/subproc.zig @@ -1228,7 +1228,11 @@ pub const PipeReader = struct { const owned = this.toOwnedSlice(); this.state = .{ .done = owned }; if (!this.isDone()) return; + // we need to ref because the process might be done and deref inside signalDoneToCmd before we call onCloseIO + this.ref(); + defer this.deref(); this.signalDoneToCmd(); + if (this.process) |process| { // this.process = null; process.onCloseIO(this.kind(process));