Skip to content

Commit 33a80a7

Browse files
[lldb][windows] fix a use before allocation crash (#170530)
1 parent 4ca61f5 commit 33a80a7

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

lldb/source/Host/windows/ProcessLauncherWindows.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ ProcessLauncherWindows::LaunchProcess(const ProcessLaunchInfo &launch_info,
8787
error.Clear();
8888

8989
std::string executable;
90-
std::vector<HANDLE> inherited_handles;
9190
STARTUPINFOEXW startupinfoex = {};
9291
STARTUPINFOW &startupinfo = startupinfoex.StartupInfo;
9392
PROCESS_INFORMATION pi = {};
@@ -107,14 +106,6 @@ ProcessLauncherWindows::LaunchProcess(const ProcessLaunchInfo &launch_info,
107106
::CloseHandle(stderr_handle);
108107
});
109108

110-
auto inherited_handles_or_err = GetInheritedHandles(
111-
launch_info, startupinfoex, stdout_handle, stderr_handle, stdin_handle);
112-
if (!inherited_handles_or_err) {
113-
error = Status(inherited_handles_or_err.getError());
114-
return HostProcess();
115-
}
116-
inherited_handles = *inherited_handles_or_err;
117-
118109
SIZE_T attributelist_size = 0;
119110
InitializeProcThreadAttributeList(/*lpAttributeList=*/nullptr,
120111
/*dwAttributeCount=*/1, /*dwFlags=*/0,
@@ -133,6 +124,14 @@ ProcessLauncherWindows::LaunchProcess(const ProcessLaunchInfo &launch_info,
133124
auto delete_attributelist = llvm::make_scope_exit(
134125
[&] { DeleteProcThreadAttributeList(startupinfoex.lpAttributeList); });
135126

127+
auto inherited_handles_or_err = GetInheritedHandles(
128+
launch_info, startupinfoex, stdout_handle, stderr_handle, stdin_handle);
129+
if (!inherited_handles_or_err) {
130+
error = Status(inherited_handles_or_err.getError());
131+
return HostProcess();
132+
}
133+
std::vector<HANDLE> inherited_handles = *inherited_handles_or_err;
134+
136135
const char *hide_console_var =
137136
getenv("LLDB_LAUNCH_INFERIORS_WITHOUT_CONSOLE");
138137
if (hide_console_var &&

0 commit comments

Comments
 (0)