HomeFreeBSD

Fix a memory leak on topology_parse().

Description

Fix a memory leak on topology_parse().

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.

Reviewed by: rgrimes
MFC after: 3 weeks.
X-MFC: r332298
Sponsored by: iXsystems Inc.
Differential Revision: https://reviews.freebsd.org/D15550

Details

Provenance
araujoAuthored on
Reviewer
rgrimes
Differential Revision
D15550: Fix a memory leak on topology_parse().
Parents
rS334198: Remove extra space before parenthesis in src.conf(5)
Branches
Unknown
Tags
Unknown