This was identified in the illumos port using the umem allocator: umem_alloc_16 leak: 1 buffer, 16 bytes ADDR BUFADDR TIMESTAMP THREAD CACHE LASTLOG CONTENTS 81e460 817fd0 570a4304d986 1 7d6668 79aa80 0 libc.so.1`strdup+0x25 topology_parse+0x2b main+0x1c5
Details
Details
- Reviewers
rew jhb - Group Reviewers
bhyve - Commits
- rG62bed9d49e41: bhyve: plug memory leak in topology_parse()
rGad3da82996ff: bhyve: plug memory leak in topology_parse()
Diff Detail
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Passed - Unit
No Test Coverage - Build Status
Buildable 44564 Build 41452: arc lint + arc unit
Event Timeline
Comment Actions
It's keeping track of the address of the buffer that needs to be freed at the end. The problem with str is that it's used with strsep() which will change the pointer, leaving it eventually as NULL, and so the original version just did free(NULL); at best, and worse in the case that an unknown key was found.
Comment Actions
In some other places that use strsep the pattern is to name this variable tofree which might be a more obvious name than o[riginal]str.