Skip to content

Commit 1d0c4f8

Browse files
committed
os: fix memory leak in userInfo()
This previously leaked memory in the ‘success’ case.
1 parent d8924a0 commit 1d0c4f8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/node_os.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ static void GetUserInfo(const FunctionCallbackInfo<Value>& args) {
360360
}
361361

362362
const int err = uv_os_get_passwd(&pwd);
363+
OnScopeLeave free_passwd([&]() { uv_os_free_passwd(&pwd); });
363364

364365
if (err) {
365366
CHECK_GE(args.Length(), 2);
@@ -389,7 +390,6 @@ static void GetUserInfo(const FunctionCallbackInfo<Value>& args) {
389390

390391
if (username.IsEmpty() || homedir.IsEmpty() || shell.IsEmpty()) {
391392
CHECK(!error.IsEmpty());
392-
uv_os_free_passwd(&pwd);
393393
env->isolate()->ThrowException(error);
394394
return;
395395
}

0 commit comments

Comments
 (0)