-
Notifications
You must be signed in to change notification settings - Fork 370
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
Fix memleak when process policies #3301
Conversation
This will fix a leak on early exit or case of single policy, but it should additionally be freed in the for-loop. But... I seriously doubt the policy does anything meaningful these days and the more merciful solution would be be just axe the whole thing. Are you actually trying to use the SELinux policy stuff for something, or is this just something spotted by static analysis? |
This is what I found by static analysis of the code. |
Yes, it should be freed in the for-loop |
You don't need to test against NULL, and you can just assign like this, it always returns NULL for this very purpose: |
Thank you for your review comments. The poptFreeContext function has no return value, is the usage of poptFreeContext declares as follows: |
What version of popt is that? Oh, at least the man page is wrong on that, it claims void but the actual header (on popt 1.19) is:
|
Okay, it returns NULL at least back to popt 1.13 and we certainly don't care about older than that. |
build/policies.c
Outdated
@@ -298,6 +299,9 @@ static rpmRC processPolicies(rpmSpec spec, Package pkg, int test) | |||
free(name); | |||
free(types); | |||
|
|||
if (optCon) |
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.
Don't bother checking for the NULL, poptFreeContext() does it 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.
done
The code has been updated. |
Thanks for the patch. It was also useful to spot the error in popt manual, submitted a fix for that: rpm-software-management/popt#125 |
Fix memleak when process policies