summaryrefslogtreecommitdiffstats
path: root/lib/libproc/proc_sym.c
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2014-08-09 12:25:06 +0000
committerdim <dim@FreeBSD.org>2014-08-09 12:25:06 +0000
commit0c41ee73837359ee311aa54d0de3bdcc391a0992 (patch)
tree40f5dd51f183e9e1cf847ff7f16c0b2f32e5cc2b /lib/libproc/proc_sym.c
parent9b2714add1a49c05905af59b1c0e04684aa0259c (diff)
downloadFreeBSD-src-0c41ee73837359ee311aa54d0de3bdcc391a0992.zip
FreeBSD-src-0c41ee73837359ee311aa54d0de3bdcc391a0992.tar.gz
In r268463, I misplaced a return in demangle(), causing the function to
erroneously skip symbols that were not mangled at all. Fix this by moving the return into the preceding if block. While here, simplify the code by letting __cxa_demangle() allocate the needed space for the demangled symbol. This also fixes a memory leak, which would occur whenever __cxa_demangle() failed. Reported by: pgj MFC after: 3 days
Diffstat (limited to 'lib/libproc/proc_sym.c')
-rw-r--r--lib/libproc/proc_sym.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/lib/libproc/proc_sym.c b/lib/libproc/proc_sym.c
index 4d60043..e1776a4 100644
--- a/lib/libproc/proc_sym.c
+++ b/lib/libproc/proc_sym.c
@@ -57,21 +57,15 @@ demangle(const char *symbol, char *buf, size_t len)
{
#ifndef NO_CXA_DEMANGLE
char *dembuf;
- size_t demlen;
if (symbol[0] == '_' && symbol[1] == 'Z' && symbol[2]) {
- dembuf = malloc(len);
- if (!dembuf)
- goto fail;
- demlen = len;
- dembuf = __cxa_demangle(symbol, dembuf, &demlen, NULL);
+ dembuf = __cxa_demangle(symbol, NULL, NULL, NULL);
if (!dembuf)
goto fail;
strlcpy(buf, dembuf, len);
free(dembuf);
+ return;
}
-
- return;
fail:
#endif /* NO_CXA_DEMANGLE */
strlcpy(buf, symbol, len);
OpenPOWER on IntegriCloud