Skip to content

Commit c1f24a5

Browse files
[windows] improve python3.dll load check (#168864)
1 parent 79c56e8 commit c1f24a5

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
@@ -477,18 +477,17 @@ bool AddPythonDLLToSearchPath() {
477477
#endif
478478

479479
#ifdef LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME
480-
/// Returns whether `python3x.dll` is in the DLL search path.
480+
/// Returns true if `python3x.dll` can be loaded.
481481
bool IsPythonDLLInPath() {
482482
#define WIDEN2(x) L##x
483483
#define WIDEN(x) WIDEN2(x)
484-
WCHAR foundPath[MAX_PATH];
485-
DWORD result =
486-
SearchPathW(nullptr, WIDEN(LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME), nullptr,
487-
MAX_PATH, foundPath, nullptr);
484+
HMODULE h = LoadLibraryW(WIDEN(LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME));
485+
if (!h)
486+
return false;
487+
FreeLibrary(h);
488+
return true;
488489
#undef WIDEN2
489490
#undef WIDEN
490-
491-
return result > 0;
492491
}
493492
#endif
494493

0 commit comments

Comments
 (0)