win: fix uv_os_environ() null pointer check

Check the pointer to the allocated memory, not the pointer to the
pointer of the allocated memory. Previously, a failed allocation of
*envitems would lead to a NULL pointer dereference.

PR-URL: https://github.com/libuv/libuv/pull/2778
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
This commit is contained in:
Rikard Falkeborn 2020-04-09 23:48:26 +02:00 committed by cjihrig
parent b44d5ee1b4
commit cd11c2b1ea
No known key found for this signature in database
GPG Key ID: 7434390BDBE9B9C5

View File

@ -1405,7 +1405,7 @@ int uv_os_environ(uv_env_item_t** envitems, int* count) {
for (penv = env, i = 0; *penv != L'\0'; penv += wcslen(penv) + 1, i++);
*envitems = uv__calloc(i, sizeof(**envitems));
if (envitems == NULL) {
if (*envitems == NULL) {
FreeEnvironmentStringsW(env);
return UV_ENOMEM;
}