Page MenuHomeFreeBSD

Fix a memory leak in newfs_msdos
Needs ReviewPublic

Authored by on Feb 20 2017, 4:36 PM.



When the input file is not a path, memory is allocated and reassigned to the variable 'fname' and never freed.

Track this use case with the new variable 'local_fname' and free the memory after its use. The fname qualify 'const' is removed because the variable really isn't const and scan-build complains of use of const with free. The variable 'ret' introduced to hold the return status of mkfs_msdos() so fname could be freed.

Test Plan

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

Diff Detail

rS FreeBSD src repository - subversion
Lint Skipped
Unit Tests Skipped

Event Timeline retitled this revision from to Fix a memory leak in newfs_msdos. updated this object. edited the test plan for this revision. (Show Details) added reviewers: stevek, imp. set the repository for this revision to rS FreeBSD src repository - subversion.