From 5e302730cd29cfeb15d32369dd2edfd9d3c82c11 Mon Sep 17 00:00:00 2001 From: Ardi Nugraha <33378542+ardi-nugraha@users.noreply.github.com> Date: Fri, 1 Dec 2023 04:54:41 +0700 Subject: [PATCH] win: honor NoDefaultCurrentDirectoryInExePath env var (#4238) Fixes: https://github.com/libuv/libuv/issues/3888 Refs: https://github.com/nodejs/node/issues/46264 --- src/win/process.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/win/process.c b/src/win/process.c index 43059858f31..117054d49e0 100644 --- a/src/win/process.c +++ b/src/win/process.c @@ -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') {