Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os: fix memory leak in userInfo() #23893

Closed
wants to merge 2 commits into from
Closed

Conversation

addaleax
Copy link
Member

This previously leaked memory in the ‘success’ case.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. os Issues and PRs related to the os subsystem. labels Oct 26, 2018
This previously leaked memory in the ‘success’ case.
@addaleax
Copy link
Member Author

src/node_os.cc Outdated
@@ -360,6 +360,7 @@ static void GetUserInfo(const FunctionCallbackInfo<Value>& args) {
}

const int err = uv_os_get_passwd(&pwd);
OnScopeLeave free_passwd([&]() { uv_os_free_passwd(&pwd); });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it safe to call it if uv_os_get_passwd returned an error?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think you’re right, we shouldn’t do that. I’ve moved it below the conditional 👍

@danbev
Copy link
Contributor

danbev commented Oct 31, 2018

Landed in d690a87.

@danbev danbev closed this Oct 31, 2018
danbev pushed a commit that referenced this pull request Oct 31, 2018
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>
targos pushed a commit that referenced this pull request Nov 1, 2018
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>
@MylesBorins
Copy link
Contributor

Lands cleanly on 10 but not on 8

It would appear the leak actually doesn't exist on 8 so I'm marking as don't land

@addaleax addaleax deleted the os-mem-leak branch November 27, 2018 00:57
MylesBorins pushed a commit that referenced this pull request Nov 27, 2018
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>
@codebytere codebytere mentioned this pull request Nov 27, 2018
rvagg pushed a commit that referenced this pull request Nov 28, 2018
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>
MylesBorins pushed a commit that referenced this pull request Nov 29, 2018
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>
@codebytere codebytere mentioned this pull request Nov 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. os Issues and PRs related to the os subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants