From cd11c2b1ea2e5103a779040d7ffa40f6a3008e6b Mon Sep 17 00:00:00 2001 From: Rikard Falkeborn Date: Thu, 9 Apr 2020 23:48:26 +0200 Subject: [PATCH] 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 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Bartosz Sosnowski --- src/win/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win/util.c b/src/win/util.c index 34a898bf..aaa7ba03 100644 --- a/src/win/util.c +++ b/src/win/util.c @@ -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; }