Skip to content

Commit 9784760

Browse files
Merge pull request #11899 from charles-zablit/charles-zablit/lldb/windows/fix-incorrect-python.dll-not-found-to-swift-release-6.2
🍒 [windows] improve python3.dll load check
2 parents 53e5d74 + 81bfb66 commit 9784760

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
@@ -474,18 +474,17 @@ bool AddPythonDLLToSearchPath() {
474474
#endif
475475

476476
#ifdef LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME
477-
/// Returns whether `python3x.dll` is in the DLL search path.
477+
/// Returns true if `python3x.dll` can be loaded.
478478
bool IsPythonDLLInPath() {
479479
#define WIDEN2(x) L##x
480480
#define WIDEN(x) WIDEN2(x)
481-
WCHAR foundPath[MAX_PATH];
482-
DWORD result =
483-
SearchPathW(nullptr, WIDEN(LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME), nullptr,
484-
MAX_PATH, foundPath, nullptr);
481+
HMODULE h = LoadLibraryW(WIDEN(LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME));
482+
if (!h)
483+
return false;
484+
FreeLibrary(h);
485+
return true;
485486
#undef WIDEN2
486487
#undef WIDEN
487-
488-
return result > 0;
489488
}
490489
#endif
491490

0 commit comments

Comments
 (0)