diff --git a/src/node_os.cc b/src/node_os.cc index d3e9460f473122..723cf18b3efd27 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -368,6 +368,8 @@ static void GetUserInfo(const FunctionCallbackInfo& args) { return args.GetReturnValue().SetUndefined(); } + OnScopeLeave free_passwd([&]() { uv_os_free_passwd(&pwd); }); + Local error; Local uid = Number::New(env->isolate(), pwd.uid); @@ -389,7 +391,6 @@ static void GetUserInfo(const FunctionCallbackInfo& args) { if (username.IsEmpty() || homedir.IsEmpty() || shell.IsEmpty()) { CHECK(!error.IsEmpty()); - uv_os_free_passwd(&pwd); env->isolate()->ThrowException(error); return; }