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:
parent
b44d5ee1b4
commit
cd11c2b1ea
@ -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;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user