summaryrefslogtreecommitdiffstats
path: root/Utilities/cmlibuv
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2023-08-02 16:36:27 (GMT)
committerBrad King <brad.king@kitware.com>2023-08-18 19:53:32 (GMT)
commit5fb17a1410268d7341c1d4241e1eb174efbab10d (patch)
treee8cc00af00395d812ccddf1213c5cf9165016c35 /Utilities/cmlibuv
parent703e3e03c30c6400602b1140140e254dc5d02c2d (diff)
downloadCMake-5fb17a1410268d7341c1d4241e1eb174efbab10d.zip
CMake-5fb17a1410268d7341c1d4241e1eb174efbab10d.tar.gz
CMake-5fb17a1410268d7341c1d4241e1eb174efbab10d.tar.bz2
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.
Diffstat (limited to 'Utilities/cmlibuv')
-rw-r--r--Utilities/cmlibuv/src/win/process.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/Utilities/cmlibuv/src/win/process.c b/Utilities/cmlibuv/src/win/process.c
index 248b7ea..3b5b2800 100644
--- a/Utilities/cmlibuv/src/win/process.c
+++ b/Utilities/cmlibuv/src/win/process.c
@@ -394,7 +394,7 @@ static WCHAR* search_path(const WCHAR *file,
name_has_ext);
while (result == NULL) {
- if (*dir_end == L'\0') {
+ if (dir_end == NULL || *dir_end == L'\0') {
break;
}
@@ -1027,22 +1027,19 @@ int uv_spawn(uv_loop_t* loop,
DWORD path_len, r;
path_len = GetEnvironmentVariableW(L"PATH", NULL, 0);
- if (path_len == 0) {
- err = GetLastError();
- goto done;
- }
-
- alloc_path = (WCHAR*) uv__malloc(path_len * sizeof(WCHAR));
- if (alloc_path == NULL) {
- err = ERROR_OUTOFMEMORY;
- goto done;
- }
- path = alloc_path;
+ if (path_len != 0) {
+ alloc_path = (WCHAR*) uv__malloc(path_len * sizeof(WCHAR));
+ if (alloc_path == NULL) {
+ err = ERROR_OUTOFMEMORY;
+ goto done;
+ }
+ path = alloc_path;
- r = GetEnvironmentVariableW(L"PATH", path, path_len);
- if (r == 0 || r >= path_len) {
- err = GetLastError();
- goto done;
+ r = GetEnvironmentVariableW(L"PATH", path, path_len);
+ if (r == 0 || r >= path_len) {
+ err = GetLastError();
+ goto done;
+ }
}
}