Skip to content

Commit

Permalink
src: cleanup in all return paths in node::Start
Browse files Browse the repository at this point in the history
`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: #21283
PR-URL: #26471
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
gireeshpunathil authored and BridgeAR committed Mar 14, 2019
1 parent d688b8a commit 12fb739
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,7 @@ inline int Start(Isolate* isolate, IsolateData* isolate_data,
HandleScope handle_scope(isolate);
Local<Context> context = NewContext(isolate);
Context::Scope context_scope(context);
int exit_code = 0;
Environment env(
isolate_data,
context,
Expand All @@ -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
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 12fb739

Please sign in to comment.