Print this page
libconv

*** 20,29 **** --- 20,31 ---- */ /* * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * + * Copyright 2018 Jason King */ #include "msg.h" #include "_debug.h" #include "libld.h"
*** 340,357 **** * Define name demanglers. */ const char * Dbg_demangle_name(const char *name) { if (DBG_NOTCLASS(DBG_C_DEMANGLE)) return (name); ! return (conv_demangle_name(name)); } const char * Elf_demangle_name(const char *name) { ! if (DBG_ISDEMANGLE()) ! return (conv_demangle_name(name)); return (name); } --- 342,378 ---- * Define name demanglers. */ const char * Dbg_demangle_name(const char *name) { + static char *buf = NULL; + if (DBG_NOTCLASS(DBG_C_DEMANGLE)) return (name); ! free(buf); ! buf = (char *)conv_demangle_name(name); ! if (buf == name) { ! buf = NULL; ! return (name); ! } ! ! return (buf); } const char * Elf_demangle_name(const char *name) { ! static char *buf = NULL; ! ! if (!DBG_ISDEMANGLE()) return (name); + + free(buf); + buf = (char *)conv_demangle_name(name); + if (buf == name) { + buf = NULL; + return (name); + } + + return (buf); }