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)
Dec 20 2023, 5:16 AM
Unknown Object (File)
Nov 28 2023, 4:09 AM
Unknown Object (File)
Nov 22 2023, 8:20 PM
Unknown Object (File)
Nov 22 2023, 8:05 PM
Unknown Object (File)
Nov 15 2023, 1:41 PM
Unknown Object (File)
Nov 13 2023, 9:21 AM
Unknown Object (File)
Nov 13 2023, 8:56 AM
Unknown Object (File)
Jul 30 2023, 11:12 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.