diff options
author | Anna Henningsen <anna@addaleax.net> | 2018-10-26 09:08:56 +0200 |
---|---|---|
committer | Daniel Bevenius <daniel.bevenius@gmail.com> | 2018-10-31 06:17:06 +0100 |
commit | d690a87b8c71208a021cbcc21b09d27007c0f9dd (patch) | |
tree | efdeccfcc3885252596722dadfe7da7847abde5e | |
parent | 6f4721b7335f7f849c04af8c1158067eaf4ddae3 (diff) | |
download | android-node-v8-d690a87b8c71208a021cbcc21b09d27007c0f9dd.tar.gz android-node-v8-d690a87b8c71208a021cbcc21b09d27007c0f9dd.tar.bz2 android-node-v8-d690a87b8c71208a021cbcc21b09d27007c0f9dd.zip |
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>
-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 6e209b2cee..486192a506 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; } |