From 7647bfe3fc358edf61e1fa15f30d06f9ee5e70a2 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 26 Nov 2019 17:00:53 +0100 Subject: [PATCH] src: keep object alive in stream_pipe code This was overlooked in a489583eda4d7cebc06516834b31dc2a4cedb1b6. Refs: https://github.com/nodejs/node/pull/30374 Backport-PR-URL: https://github.com/nodejs/node/pull/32301 PR-URL: https://github.com/nodejs/node/pull/30666 Fixes: https://github.com/nodejs/node/issues/30643 Reviewed-By: Rich Trott Reviewed-By: James M Snell --- src/stream_pipe.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stream_pipe.cc b/src/stream_pipe.cc index 65b5507efe6fd6..7c10f4a5588cad 100644 --- a/src/stream_pipe.cc +++ b/src/stream_pipe.cc @@ -73,7 +73,7 @@ void StreamPipe::Unpipe() { // inside the garbage collector, so we can’t run JS here. HandleScope handle_scope(env()->isolate()); BaseObjectPtr strong_ref{this}; - env()->SetImmediate([this](Environment* env) { + env()->SetImmediate([this, strong_ref](Environment* env) { HandleScope handle_scope(env->isolate()); Context::Scope context_scope(env->context()); Local object = this->object();