From 81bfb660674201b2bd0c217cd944fea1367f3ff7 Mon Sep 17 00:00:00 2001 From: Charles Zablit Date: Mon, 24 Nov 2025 18:40:45 +0100 Subject: [PATCH] [windows] improve python3.dll load check (#168864) --- lldb/tools/driver/Driver.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index cfda2cc73b274..a5a0b81766f50 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -474,18 +474,17 @@ bool AddPythonDLLToSearchPath() { #endif #ifdef LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME -/// Returns whether `python3x.dll` is in the DLL search path. +/// Returns true if `python3x.dll` can be loaded. bool IsPythonDLLInPath() { #define WIDEN2(x) L##x #define WIDEN(x) WIDEN2(x) - WCHAR foundPath[MAX_PATH]; - DWORD result = - SearchPathW(nullptr, WIDEN(LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME), nullptr, - MAX_PATH, foundPath, nullptr); + HMODULE h = LoadLibraryW(WIDEN(LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME)); + if (!h) + return false; + FreeLibrary(h); + return true; #undef WIDEN2 #undef WIDEN - - return result > 0; } #endif