Print this page
libconv

@@ -20,10 +20,11 @@
  */
 
 /*
  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
+ * Copyright 2018 Jason King
  */
 
 /*      Copyright (c) 1988 AT&T */
 /*        All Rights Reserved   */
 

@@ -1309,13 +1310,11 @@
 demangled_name(char *s)
 {
         const char *name;
         size_t  len;
 
-        name = conv_demangle_name(s);
-
-        if (strcmp(name, s) == 0)
+        if ((name = conv_demangle_name(s)) == s)
                 return (s);
 
         if (format_buf != NULL)
                 free(format_buf);
 

@@ -1322,10 +1321,11 @@
         len = strlen(name) + strlen(FORMAT_BUF) + strlen(s) + 1;
         format_buf = malloc(len);
         if (format_buf == NULL)
                 return (s);
         (void) snprintf(format_buf, len, FORMAT_BUF, name, s);
+        free((void *)name);
         return (format_buf);
 }
 
 /* getname - get the name of a symbol in a permanent fashion */
 static char *