src: keep object alive in stream_pipe code

This was overlooked in a489583eda.

Refs: https://github.com/nodejs/node/pull/30374

PR-URL: https://github.com/nodejs/node/pull/30666
Fixes: https://github.com/nodejs/node/issues/30643
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Anna Henningsen
2019-11-26 17:00:53 +01:00
parent 8792c3feb8
commit f73716d35a

View File

@@ -72,7 +72,7 @@ void StreamPipe::Unpipe() {
// inside the garbage collector, so we cant run JS here.
HandleScope handle_scope(env()->isolate());
BaseObjectPtr<StreamPipe> 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> object = this->object();