Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ac73050

Browse filesBrowse files
addaleaxMylesBorins
authored andcommitted
os: fix memory leak in userInfo()
This previously leaked memory in the ‘success’ case. PR-URL: #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>
1 parent 1c9ae77 commit ac73050
Copy full SHA for ac73050

File tree

Expand file treeCollapse file tree

1 file changed

+2
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+2
-1
lines changed
Open diff view settings
Collapse file

‎src/node_os.cc‎

Copy file name to clipboardExpand all lines: src/node_os.cc
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,8 @@ static void GetUserInfo(const FunctionCallbackInfo<Value>& args) {
368368
return args.GetReturnValue().SetUndefined();
369369
}
370370

371+
OnScopeLeave free_passwd([&]() { uv_os_free_passwd(&pwd); });
372+
371373
Local<Value> error;
372374

373375
Local<Value> uid = Number::New(env->isolate(), pwd.uid);
@@ -389,7 +391,6 @@ static void GetUserInfo(const FunctionCallbackInfo<Value>& args) {
389391

390392
if (username.IsEmpty() || homedir.IsEmpty() || shell.IsEmpty()) {
391393
CHECK(!error.IsEmpty());
392-
uv_os_free_passwd(&pwd);
393394
env->isolate()->ThrowException(error);
394395
return;
395396
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.