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:
parent
ad618647b9
commit
b44d5ee1b4
@ -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++) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user