From 9640bc6510084cc681c23deb7ec6f4993fa1ccad Mon Sep 17 00:00:00 2001 From: Ambuj Vashistha Date: Sun, 7 Dec 2025 02:34:49 +0530 Subject: [PATCH] unix,win: fix leak in uv_os_environ error path (#4960) --- src/unix/core.c | 2 +- src/win/util.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unix/core.c b/src/unix/core.c index 118bc5759..cde4dc444 100644 --- a/src/unix/core.c +++ b/src/unix/core.c @@ -1533,7 +1533,7 @@ int uv_os_environ(uv_env_item_t** envitems, int* count) { fail: for (i = 0; i < cnt; i++) { - envitem = &(*envitems)[cnt]; + envitem = &(*envitems)[i]; uv__free(envitem->name); } uv__free(*envitems); diff --git a/src/win/util.c b/src/win/util.c index 9fb5694c9..ded589c75 100644 --- a/src/win/util.c +++ b/src/win/util.c @@ -1280,7 +1280,7 @@ fail: FreeEnvironmentStringsW(env); for (i = 0; i < cnt; i++) { - envitem = &(*envitems)[cnt]; + envitem = &(*envitems)[i]; uv__free(envitem->name); } uv__free(*envitems);