Skip to content

Commit 12fb739

Browse files
gireeshpunathilBridgeAR
authored andcommitted
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: #21283 PR-URL: #26471 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent d688b8a commit 12fb739

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Diff for: src/node.cc

+5-2
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,7 @@ inline int Start(Isolate* isolate, IsolateData* isolate_data,
760760
HandleScope handle_scope(isolate);
761761
Local<Context> context = NewContext(isolate);
762762
Context::Scope context_scope(context);
763+
int exit_code = 0;
763764
Environment env(
764765
isolate_data,
765766
context,
@@ -780,7 +781,8 @@ inline int Start(Isolate* isolate, IsolateData* isolate_data,
780781
true);
781782
if (env.options()->debug_options().inspector_enabled &&
782783
!env.inspector_agent()->IsListening()) {
783-
return 12; // Signal internal error.
784+
exit_code = 12; // Signal internal error.
785+
goto exit;
784786
}
785787
#else
786788
// 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,
821823

822824
env.set_trace_sync_io(false);
823825

824-
const int exit_code = EmitExit(&env);
826+
exit_code = EmitExit(&env);
825827

826828
WaitForInspectorDisconnect(&env);
827829

830+
exit:
828831
env.set_can_call_into_js(false);
829832
env.stop_sub_worker_contexts();
830833
uv_tty_reset_mode();

0 commit comments

Comments
 (0)