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

Fix potential mem leak in poptReadConfigFile() #59

Merged
merged 1 commit into from
Jul 19, 2021

Conversation

dmnks
Copy link
Contributor

@dmnks dmnks commented Jul 19, 2021

While it seems that the actual implementation of poptReadFile()
shouldn't allocate the passed buffer (b) if the number of bytes (nb) is
zero (see the read(2) call in that function), it's still up to the
caller to take care of this resource, so let's just do that by bailing
out via "exit" where the freeing happens.

Found by Coverity.

@ffesti
Copy link

ffesti commented Jul 19, 2021

t should probably be initialized to NULL to not pass an undefined pointer to free().

@dmnks
Copy link
Contributor Author

dmnks commented Jul 19, 2021

Nice find, I'll fix that too.

While it seems that the actual implementation of poptReadFile()
shouldn't allocate the passed buffer (b) if the number of bytes (nb) is
zero (see the read(2) call in that function), it's still up to the
caller to take care of this resource, so let's just do that by bailing
out via "exit" where the freeing happens.

Also initialize t to NULL to avoid freeing an undefined pointer.

Found by Coverity.
@dmnks
Copy link
Contributor Author

dmnks commented Jul 19, 2021

Updated.

@ffesti ffesti merged commit 70011cc into rpm-software-management:master Jul 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants