Page MenuHomeFreeBSD

Fix a memory leak in grep
Needs ReviewPublic

Authored by trix_juniper.net on Feb 24 2017, 12:17 AM.

Details

Reviewers
stevek
ache
Summary

savedir.c savedir When the realloc of the variable name_space fails, free the memory assigned to name_space before returning

Test Plan

Run clang's static analyzer, scan-build, to reproduce the problem. After, run scan-build again to verify the resolution.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

trix_juniper.net retitled this revision from to Fix a memory leak in grep.
trix_juniper.net updated this object.
trix_juniper.net edited the test plan for this revision. (Show Details)
trix_juniper.net added reviewers: stevek, ache.
trix_juniper.net set the repository for this revision to rS FreeBSD src repository.
ache edited edge metadata.Feb 24 2017, 6:27 AM

See BSDism reallocf(3) instead, it does free() automatically.

Yes I am aware of the bsd-ism.
Generally it isn¹t a good idea to use ism¹s.
In this case the problem is in grep which is gnu, and not bsd.
Tom

ache added a comment.Feb 25 2017, 9:00 AM

Ah, it is gnu one. Sorry I don't check first. Thats OK.