-
Notifications
You must be signed in to change notification settings - Fork 424
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
free strdupped temporary variable in joinpath #1438
free strdupped temporary variable in joinpath #1438
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch. Should the free also go into the preceding if
statement just in case the function bombs out?
@@ -191,6 +191,8 @@ char *joinpath(const char * path1, const char * path2_in) { | |||
ABORT(255); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the free also go in this if statement above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't think it was worth doing since the program dies there anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your right.
I noticed that indeed where joinpath and strdup are used, most of the time it leaks memory. It was my intention to fix it in a few places, but the memory leaking is quite common. I have started working on it, and will probably fix the memory leaks in small steps, in many commits to make the fix easier to test and review. |
Yes, it is, it is one of the many places where strdup without a free leaks memory. It was my intention to fix the memory leaks bit by bit, mostly by using static variables where possible. In fact, some of the fixes are already in my "strings-fix" branch for which I have not made any pull requests yet - but feel free to have a look. |
Description of the Pull Request (PR):
I noticed a strdup() in joinpath() that was not getting freed and not needed after the function returns. This adds the free().
This fixes or addresses the following GitHub issues:
Checkoff for all PRs:
make test
Attn: @singularityware-admin