Print this page
libconv

@@ -23,10 +23,11 @@
  * Copyright (c) 1988 AT&T
  * Copyright (c) 1989 AT&T
  * All Rights Reserved
  *
  * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2018 Jason King
  */
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>

@@ -803,20 +804,20 @@
                 buf->indx = i;
                 /* allow to work on machines where NULL-derefs dump core */
                 if (sym.st_name == 0)
                         buf->name = "";
                 else if (C_flag) {
-                        const char *dn;
+                        const char *dn = NULL;
                         char *name = (char *)elf_strptr(elf, link, sym.st_name);
+
                         dn = conv_demangle_name(name);
-                        if (strcmp(dn, name) == 0) {    /* Not demangled */
-                                if (exotic(name)) {
+                        if (dn != name) {
+                                name = FormatName(name, dn);
+                                free((void *)dn);
+                        } else if (exotic(name)) {
                                         name = FormatName(name, d_buf);
                                 }
-                        } else {  /* name demangled */
-                                name = FormatName(name, dn);
-                        }
                         buf->name = name;
                 }
                 else
                         buf->name = (char *)elf_strptr(elf, link, sym.st_name);