win: honor NoDefaultCurrentDirectoryInExePath env var (#4238)

Fixes: https://github.com/libuv/libuv/issues/3888
Refs: https://github.com/nodejs/node/issues/46264
This commit is contained in:
Ardi Nugraha 2023-12-01 04:54:41 +07:00 committed by GitHub
parent a5c01d4de3
commit 5e302730cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -377,11 +377,13 @@ static WCHAR* search_path(const WCHAR *file,
} else {
dir_end = path;
/* The file is really only a name; look in cwd first, then scan path */
result = path_search_walk_ext(L"", 0,
file, file_len,
cwd, cwd_len,
name_has_ext);
if (NeedCurrentDirectoryForExePathW(L"")) {
/* The file is really only a name; look in cwd first, then scan path */
result = path_search_walk_ext(L"", 0,
file, file_len,
cwd, cwd_len,
name_has_ext);
}
while (result == NULL) {
if (dir_end == NULL || *dir_end == L'\0') {