Print this page
cleanup
libconv
*** 475,506 ****
/* demangle C++ names */
static char *
demangled_name(char *s)
{
static char *buf = NULL;
! const char *dn;
size_t len;
! dn = conv_demangle_name(s);
/*
* If not demangled, just return the symbol name
*/
! if (strcmp(s, dn) == 0)
return (s);
- /*
- * Demangled. Format it
- */
- if (buf != NULL)
- free(buf);
-
len = strlen(dn) + strlen(s) + 4;
if ((buf = malloc(len)) == NULL)
return (s);
! (void) snprintf(buf, len, "%s\t[%s]", dn, s);
return (buf);
}
/*
* Print the symbol table. Input is an ELF file descriptor, a
--- 475,510 ----
/* demangle C++ names */
static char *
demangled_name(char *s)
{
static char *buf = NULL;
! size_t buflen = 0;
! char *dn;
size_t len;
! dn = (char *)conv_demangle_name(s);
/*
* If not demangled, just return the symbol name
*/
! if (dn == s)
return (s);
len = strlen(dn) + strlen(s) + 4;
+
+ if (buflen < len) {
+ free(buf);
if ((buf = malloc(len)) == NULL)
return (s);
+ buflen = len;
+ }
! /*
! * Demangled. Format it
! */
! (void) snprintf(buf, buflen, "%s\t[%s]", dn, s);
! free(dn);
return (buf);
}
/*
* Print the symbol table. Input is an ELF file descriptor, a
*** 524,534 ****
if (gelf_getclass(elf_file) == ELFCLASS64)
adj = 8;
while (range > 0) {
! char *sym_name = (char *)0;
int type, bind;
int specsec;
unsigned int shndx;
(void) gelf_getsym(sym_data, index, &sym);
--- 528,538 ----
if (gelf_getclass(elf_file) == ELFCLASS64)
adj = 8;
while (range > 0) {
! char *sym_name = NULL;
int type, bind;
int specsec;
unsigned int shndx;
(void) gelf_getsym(sym_data, index, &sym);