1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-16 05:26:58 +08:00

libuv: win,spawn: allow %PATH% to be unset

Backport libuv commit `c97017dd` (win,spawn: allow `%PATH%` to be unset,
2023-08-14).

See https://github.com/libuv/libuv/pull/4116.
This commit is contained in:
Kyle Edwards
2023-08-02 12:36:27 -04:00
committed by Brad King
parent 703e3e03c3
commit 5fb17a1410

View File

@@ -394,7 +394,7 @@ static WCHAR* search_path(const WCHAR *file,
name_has_ext); name_has_ext);
while (result == NULL) { while (result == NULL) {
if (*dir_end == L'\0') { if (dir_end == NULL || *dir_end == L'\0') {
break; break;
} }
@@ -1027,22 +1027,19 @@ int uv_spawn(uv_loop_t* loop,
DWORD path_len, r; DWORD path_len, r;
path_len = GetEnvironmentVariableW(L"PATH", NULL, 0); path_len = GetEnvironmentVariableW(L"PATH", NULL, 0);
if (path_len == 0) { if (path_len != 0) {
err = GetLastError(); alloc_path = (WCHAR*) uv__malloc(path_len * sizeof(WCHAR));
goto done; if (alloc_path == NULL) {
} err = ERROR_OUTOFMEMORY;
goto done;
}
path = alloc_path;
alloc_path = (WCHAR*) uv__malloc(path_len * sizeof(WCHAR)); r = GetEnvironmentVariableW(L"PATH", path, path_len);
if (alloc_path == NULL) { if (r == 0 || r >= path_len) {
err = ERROR_OUTOFMEMORY; err = GetLastError();
goto done; goto done;
} }
path = alloc_path;
r = GetEnvironmentVariableW(L"PATH", path, path_len);
if (r == 0 || r >= path_len) {
err = GetLastError();
goto done;
} }
} }