unix: 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:27:16 +02:00 committed by cjihrig
parent ad618647b9
commit b44d5ee1b4
No known key found for this signature in database
GPG Key ID: 7434390BDBE9B9C5

View File

@ -1258,7 +1258,7 @@ int uv_os_environ(uv_env_item_t** envitems, int* count) {
*envitems = uv__calloc(i, sizeof(**envitems));
if (envitems == NULL)
if (*envitems == NULL)
return UV_ENOMEM;
for (j = 0, cnt = 0; j < i; j++) {