Page MenuHomeFreeBSD

Fix a memory leak in telnetd

Authored by on Feb 20 2017, 3:55 PM.



Fix memory leak in edithost

The problem is that when the parameter 'pat' is null, the function locally allocates a NULL string but never frees it.

Instead of tracking the local alloc, it is noted that the while(*pat) never enters when there is a local alloc.
So instead of doing the local alloc, check that 'pat' is null before the while(*pat) loop.

Test Plan

Run clang's static analyzer, scan-build, before to find the problem; run scan-build after to verify problem is resolved.

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 telnetd. updated this object. edited the test plan for this revision. (Show Details) added reviewers: stevek, markm. set the repository for this revision to rS FreeBSD src repository.
markm accepted this revision.Feb 24 2017, 6:34 PM
markm edited edge metadata.

Looks good to me.

364 ↗(On Diff #25424)

Oooh, yuk. Well spotted.

This revision is now accepted and ready to land.Feb 24 2017, 6:34 PM

Credit goes to clang¹s static analyzer scan-build.
I only read the reports it generated.

This revision was automatically updated to reflect the committed changes.