From b44d5ee1b418420243793289c17308c658ce1458 Mon Sep 17 00:00:00 2001 From: Rikard Falkeborn Date: Thu, 9 Apr 2020 23:27:16 +0200 Subject: [PATCH] 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 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Bartosz Sosnowski --- src/unix/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/core.c b/src/unix/core.c index 39145d1a..c3812d2d 100644 --- a/src/unix/core.c +++ b/src/unix/core.c @@ -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++) {