Page MenuHomeFreeBSD

Fix a memory leak in ccdconfig
ClosedPublic

Authored by trix_juniper.net on Mar 14 2017, 3:11 AM.
Tags
None
Referenced Files
F139538025: D9996.id26241.diff
Sat, Dec 13, 5:57 AM
F139516531: D9996.id26241.diff
Fri, Dec 12, 11:39 PM
Unknown Object (File)
Tue, Dec 9, 7:44 AM
Unknown Object (File)
Tue, Nov 18, 3:22 AM
Unknown Object (File)
Nov 11 2025, 9:41 AM
Unknown Object (File)
Oct 26 2025, 12:46 PM
Unknown Object (File)
Oct 22 2025, 4:50 AM
Unknown Object (File)
Oct 16 2025, 12:43 PM
Subscribers

Details

Reviewers
imp
uqs
Summary

ccdconfig.c do_all
Fix the memory leak of realloc failure by using realocf instead.

Test Plan

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

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

Hmmm... In this case it wouldn't be a lot more effort to just use realloc() and free(). That said, this tool is specific to FreeBSD anyway.

This revision is now accepted and ready to land.Mar 14 2017, 11:43 AM
imp added inline comments.
sbin/ccdconfig/ccdconfig.c
315

While this is a simple fix, what's the point?
We return from this function and exit right away...
No objection,

I am pedantically scrubbing all of the memory leaks and this is a leak.
Problems must fixed so they don¹t turn up in future scans.

imp added a project: srcmgr.

Actually, this is wrong. reallocf will return argv when we can't allocate new memory. So we'd never hit the warn and return.