Page MenuHomeFreeBSD

Fix a memory leak with fw_check_device_ready

Authored by stevek on Feb 18 2017, 1:02 PM.



The memory assigned to the local variable 'ptr' is freed

Test Plan

Run clang's static analyzer scan-build before to find the problem. Run scan-build after to verify the problem is fixed.

Diff Detail

rS FreeBSD src repository
Lint Skipped
Unit Tests Skipped

Event Timeline retitled this revision from to Fix a memory leak with fw_check_device_ready. updated this object. edited the test plan for this revision. (Show Details) added reviewers: stevek, ken. set the repository for this revision to rS FreeBSD src repository.
ken requested changes to this revision.Feb 20 2017, 2:43 PM
ken edited edge metadata.

Just take out the if statement and it's fine.


Good catch. Since ptr is always either NULL or malloced memory, you can just pass it in to free(3) without the if statement. (free(3) will do nothing if the pointer is NULL.)

This revision now requires changes to proceed.Feb 20 2017, 2:43 PM
stevek commandeered this revision.May 18 2019, 5:46 PM
stevek edited reviewers, added:; removed: stevek.

I will update and commit with the requested changes.

stevek abandoned this revision.May 18 2019, 5:51 PM

Abandon, since this has already been addressed.