Page MenuHomeFreeBSD

Fix memory leaks in libdtrace

Authored by on Feb 21 2017, 7:18 PM.



dt_open.c dt_provmod_open
When realloc fails, the original pointer is still valid, so it must be freed.

dt_open.c dt_vopen
When the malloc of dtp fails, the memory/structure previously assigned to provmod must be freed. dt_provmod_destroy handles the case when provmod == NULL so there is no need for special handling of jumping over the setup of provmod.

dt_strtab.c dt_strtab_insert
When the call to dt_strtab_copyin fails, it is necessary to free the locally allocated memory assigned to 'hp' before returning early.

Test Plan

Run clang's static analyzer scan-build before to reproduce the problem, run scan-build after to verify resolution of the problem.

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 memory leaks in libdtrace. updated this object. edited the test plan for this revision. (Show Details) set the repository for this revision to rS FreeBSD src repository. edited reviewers, added: stevek, markj; removed: gnn.Feb 21 2017, 7:19 PM
markj accepted this revision.Feb 21 2017, 10:27 PM
markj edited edge metadata.
This revision is now accepted and ready to land.Feb 21 2017, 10:27 PM
This revision was automatically updated to reflect the committed changes.