When a symbol cannot be demangled in ada_demangle a new demangled VEC
will be allocated without deleting the demangled VEC already in use.
Running testsuite/test-demangle under valgrind will show the leak for
this entry in testsuite/demangle-expected:
# Elaborated flag (not demangled)
--format=gnat
x_E
<x_E>
11 bytes in 1 blocks are definitely lost in loss record 1 of 1
at 0x4C27BE3: malloc (vg_replace_malloc.c:299)
by 0x413FE7: xmalloc (xmalloc.c:148)
by 0x4025EC: ada_demangle (cplus-dem.c:930)
by 0x402C59: cplus_demangle (cplus-dem.c:892)
by 0x400FEC: main (test-demangle.c:317)
libiberty/ChangeLog:
* cplus-dem.c (ada_demangle): Initialize demangled to NULL and
XDELETEVEC demangled when unknown.
+2016-10-31 Mark Wielaard <mjw@redhat.com>
+
+ * cplus-dem.c (ada_demangle): Initialize demangled to NULL and
+ XDELETEVEC demangled when unknown.
+
2016-10-17 Nick Clifton <nickc@redhat.com>
* Sync with gcc.
int len0;
const char* p;
char *d;
- char *demangled;
+ char *demangled = NULL;
/* Discard leading _ada_, which is used for library level subprograms. */
if (strncmp (mangled, "_ada_", 5) == 0)
return demangled;
unknown:
+ XDELETEVEC (demangled);
len0 = strlen (mangled);
demangled = XNEWVEC (char, len0 + 3);