diff options
author | Anna Henningsen <anna@addaleax.net> | 2018-10-26 10:08:56 +0300 |
---|---|---|
committer | Daniel Bevenius <daniel.bevenius@gmail.com> | 2018-10-31 08:17:06 +0300 |
commit | d690a87b8c71208a021cbcc21b09d27007c0f9dd (patch) | |
tree | efdeccfcc3885252596722dadfe7da7847abde5e /src/node_os.cc | |
parent | 6f4721b7335f7f849c04af8c1158067eaf4ddae3 (diff) |
os: fix memory leak in `userInfo()`
This previously leaked memory in the ‘success’ case.
PR-URL: https://github.com/nodejs/node/pull/23893
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_os.cc')
-rw-r--r-- | src/node_os.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/node_os.cc b/src/node_os.cc index 6e209b2ceec..486192a5061 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -368,6 +368,8 @@ static void GetUserInfo(const FunctionCallbackInfo<Value>& args) { return args.GetReturnValue().SetUndefined(); } + OnScopeLeave free_passwd([&]() { uv_os_free_passwd(&pwd); }); + Local<Value> error; Local<Value> uid = Number::New(env->isolate(), pwd.uid); @@ -389,7 +391,6 @@ static void GetUserInfo(const FunctionCallbackInfo<Value>& args) { if (username.IsEmpty() || homedir.IsEmpty() || shell.IsEmpty()) { CHECK(!error.IsEmpty()); - uv_os_free_passwd(&pwd); env->isolate()->ThrowException(error); return; } |