Skip to content

Commit 9f25a64

Browse files
[windows] improve python3.dll load check (llvm#168864)
(cherry picked from commit c1f24a5)
1 parent 219dd76 commit 9f25a64

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

lldb/tools/driver/Driver.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -487,18 +487,17 @@ bool AddPythonDLLToSearchPath() {
487487
#endif
488488

489489
#ifdef LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME
490-
/// Returns whether `python3x.dll` is in the DLL search path.
490+
/// Returns true if `python3x.dll` can be loaded.
491491
bool IsPythonDLLInPath() {
492492
#define WIDEN2(x) L##x
493493
#define WIDEN(x) WIDEN2(x)
494-
WCHAR foundPath[MAX_PATH];
495-
DWORD result =
496-
SearchPathW(nullptr, WIDEN(LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME), nullptr,
497-
MAX_PATH, foundPath, nullptr);
494+
HMODULE h = LoadLibraryW(WIDEN(LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME));
495+
if (!h)
496+
return false;
497+
FreeLibrary(h);
498+
return true;
498499
#undef WIDEN2
499500
#undef WIDEN
500-
501-
return result > 0;
502501
}
503502
#endif
504503

0 commit comments

Comments
 (0)