Page MenuHomeFreeBSD

Fix a memory leak on topology_parse().
ClosedPublic

Authored by araujo on May 24 2018, 9:23 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Oct 17, 10:30 PM
Unknown Object (File)
Sat, Sep 27, 11:31 PM
Unknown Object (File)
Sep 17 2025, 3:02 PM
Unknown Object (File)
Sep 5 2025, 4:13 AM
Unknown Object (File)
Aug 25 2025, 7:00 PM
Unknown Object (File)
Aug 2 2025, 2:59 AM
Unknown Object (File)
Jul 23 2025, 12:47 PM
Unknown Object (File)
Jul 11 2025, 9:24 AM
Subscribers

Details

Summary

strdup(3) allocates memory for a copy of the string, does the copy and returns a pointer to it. If there is no sufficient memory NULL is returned and the global errno is set to ENOMEM. We do a sanity check to see if it was possible to allocate enough memory.

Also as we allocate memory, we need to free this memory used. OR it will going out of scope leaks the storage it points to.

Test Plan

smoke tests using clang and gcc47.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

araujo added reviewers: grehan, neel, tychon, jhb, anish.
This revision is now accepted and ready to land.May 24 2018, 1:15 PM

Please mark the commit as MFC-X with https://svnweb.freebsd.org/changeset/base/332298

Hi,

Isn't it X-MFC? I got confused after see another review related with MFC after and before! But I'm almost sure it is X-MFC.

Best,

This revision was automatically updated to reflect the committed changes.