Page MenuHomeFreeBSD

Fix a memory leak in libutil

Authored by on Mar 2 2017, 3:19 PM.



kinfo_getvmobject.c kinfo_getvmobject
When sysctlbyname fails, free buf before returning.

Test Plan

Use clang's static analyzer, scan-build, to find the problem and show resolution.

Diff Detail

rS FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline retitled this revision from to Fix a memory leak in libutil. updated this object. edited the test plan for this revision. (Show Details) added reviewers: stevek, jhb. set the repository for this revision to rS FreeBSD src repository.
jhb accepted this revision.Mar 2 2017, 5:13 PM
jhb edited edge metadata.

Hmm, I was going to suggest looking in other places in libutil that I copied this from, but it seems other kinfo_getfoo() functions don't use a loop to retry but just add a fudge factor to the size and hope it is enough.

This revision is now accepted and ready to land.Mar 2 2017, 5:13 PM
This revision was automatically updated to reflect the committed changes.