From e029bc94e6404ac79cf304abbbd43325d407f668 Mon Sep 17 00:00:00 2001 From: Gireesh Punathil Date: Wed, 6 Mar 2019 09:28:34 -0500 Subject: [PATCH] src: cleanup in all return paths in node::Start `node::Start` creates a number of artifacts in its scope which are cleaned up in the exit path, but there is at least one path where the cleanups are bypassed. Force all paths follow the exit sequence. Refs: https://github.com/nodejs/node/pull/21283 PR-URL: https://github.com/nodejs/node/pull/26471 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Joyee Cheung Reviewed-By: Richard Lau Reviewed-By: Ruben Bridgewater --- src/node.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/node.cc b/src/node.cc index f55c1df4e8ba34..4def46ee167dbd 100644 --- a/src/node.cc +++ b/src/node.cc @@ -760,6 +760,7 @@ inline int Start(Isolate* isolate, IsolateData* isolate_data, HandleScope handle_scope(isolate); Local context = NewContext(isolate); Context::Scope context_scope(context); + int exit_code = 0; Environment env( isolate_data, context, @@ -780,7 +781,8 @@ inline int Start(Isolate* isolate, IsolateData* isolate_data, true); if (env.options()->debug_options().inspector_enabled && !env.inspector_agent()->IsListening()) { - return 12; // Signal internal error. + exit_code = 12; // Signal internal error. + goto exit; } #else // inspector_enabled can't be true if !HAVE_INSPECTOR or !NODE_USE_V8_PLATFORM @@ -821,10 +823,11 @@ inline int Start(Isolate* isolate, IsolateData* isolate_data, env.set_trace_sync_io(false); - const int exit_code = EmitExit(&env); + exit_code = EmitExit(&env); WaitForInspectorDisconnect(&env); +exit: env.set_can_call_into_js(false); env.stop_sub_worker_contexts(); uv_tty_reset_mode();