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, Nov 29, 3:27 PM
Unknown Object (File)
Thu, Nov 28, 9:08 AM
Unknown Object (File)
Sep 25 2024, 12:09 AM
Unknown Object (File)
Sep 20 2024, 9:53 PM
Unknown Object (File)
Sep 19 2024, 4:40 AM
Unknown Object (File)
Sep 17 2024, 3:13 PM
Unknown Object (File)
Sep 15 2024, 3:16 PM
Unknown Object (File)
Sep 7 2024, 10:46 PM
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.