Page MenuHomeFreeBSD

Fix a memory leak in grep
Needs ReviewPublic

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



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

rS FreeBSD src repository
Lint Skipped
Unit Tests Skipped

Event Timeline retitled this revision from to Fix a memory leak in grep. updated this object. edited the test plan for this revision. (Show Details) added reviewers: stevek, ache. 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.

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

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