Author: Charles Zablit
Date: 2025-12-03T18:59:45Z
New Revision: 33a80a7d8e34b4448f7a3af64ba1ec3a56c1e553

URL: 
https://github.com/llvm/llvm-project/commit/33a80a7d8e34b4448f7a3af64ba1ec3a56c1e553
DIFF: 
https://github.com/llvm/llvm-project/commit/33a80a7d8e34b4448f7a3af64ba1ec3a56c1e553.diff

LOG: [lldb][windows] fix a use before allocation crash (#170530)

Added: 
    

Modified: 
    lldb/source/Host/windows/ProcessLauncherWindows.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Host/windows/ProcessLauncherWindows.cpp 
b/lldb/source/Host/windows/ProcessLauncherWindows.cpp
index 3c0da1a1e70db..2f78ef80f385e 100644
--- a/lldb/source/Host/windows/ProcessLauncherWindows.cpp
+++ b/lldb/source/Host/windows/ProcessLauncherWindows.cpp
@@ -87,7 +87,6 @@ ProcessLauncherWindows::LaunchProcess(const ProcessLaunchInfo 
&launch_info,
   error.Clear();
 
   std::string executable;
-  std::vector<HANDLE> inherited_handles;
   STARTUPINFOEXW startupinfoex = {};
   STARTUPINFOW &startupinfo = startupinfoex.StartupInfo;
   PROCESS_INFORMATION pi = {};
@@ -107,14 +106,6 @@ ProcessLauncherWindows::LaunchProcess(const 
ProcessLaunchInfo &launch_info,
       ::CloseHandle(stderr_handle);
   });
 
-  auto inherited_handles_or_err = GetInheritedHandles(
-      launch_info, startupinfoex, stdout_handle, stderr_handle, stdin_handle);
-  if (!inherited_handles_or_err) {
-    error = Status(inherited_handles_or_err.getError());
-    return HostProcess();
-  }
-  inherited_handles = *inherited_handles_or_err;
-
   SIZE_T attributelist_size = 0;
   InitializeProcThreadAttributeList(/*lpAttributeList=*/nullptr,
                                     /*dwAttributeCount=*/1, /*dwFlags=*/0,
@@ -133,6 +124,14 @@ ProcessLauncherWindows::LaunchProcess(const 
ProcessLaunchInfo &launch_info,
   auto delete_attributelist = llvm::make_scope_exit(
       [&] { DeleteProcThreadAttributeList(startupinfoex.lpAttributeList); });
 
+  auto inherited_handles_or_err = GetInheritedHandles(
+      launch_info, startupinfoex, stdout_handle, stderr_handle, stdin_handle);
+  if (!inherited_handles_or_err) {
+    error = Status(inherited_handles_or_err.getError());
+    return HostProcess();
+  }
+  std::vector<HANDLE> inherited_handles = *inherited_handles_or_err;
+
   const char *hide_console_var =
       getenv("LLDB_LAUNCH_INFERIORS_WITHOUT_CONSOLE");
   if (hide_console_var &&


        
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to