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>
This commit is contained in:
parent
6f4721b733
commit
d690a87b8c
@ -368,6 +368,8 @@ static void GetUserInfo(const FunctionCallbackInfo<Value>& args) {
|
|||||||
return args.GetReturnValue().SetUndefined();
|
return args.GetReturnValue().SetUndefined();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OnScopeLeave free_passwd([&]() { uv_os_free_passwd(&pwd); });
|
||||||
|
|
||||||
Local<Value> error;
|
Local<Value> error;
|
||||||
|
|
||||||
Local<Value> uid = Number::New(env->isolate(), pwd.uid);
|
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()) {
|
if (username.IsEmpty() || homedir.IsEmpty() || shell.IsEmpty()) {
|
||||||
CHECK(!error.IsEmpty());
|
CHECK(!error.IsEmpty());
|
||||||
uv_os_free_passwd(&pwd);
|
|
||||||
env->isolate()->ThrowException(error);
|
env->isolate()->ThrowException(error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user