From owner-svn-src-stable-10@FreeBSD.ORG Tue Aug 12 18:05:25 2014 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 623947AE for ; Tue, 12 Aug 2014 18:05:25 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A18F7371A for ; Tue, 12 Aug 2014 17:56:48 +0000 (UTC) Received: from dim (uid 1236) (envelope-from dim@FreeBSD.org) id 6840 by svn.freebsd.org (DragonFly Mail Agent v0.9+); Tue, 12 Aug 2014 17:56:48 +0000 From: Dimitry Andric Date: Tue, 12 Aug 2014 17:56:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r269885 - stable/10/lib/libproc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <53ea5560.6840.ea7a307@svn.freebsd.org> X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Aug 2014 18:05:25 -0000 Author: dim Date: Tue Aug 12 17:56:48 2014 New Revision: 269885 URL: http://svnweb.freebsd.org/changeset/base/269885 Log: MFC r269750: In r268463, I misplaced a return in demangle(), causing the function to erroneously skip symbols that were not mangled at all. Fix this by moving the return into the preceding if block. While here, simplify the code by letting __cxa_demangle() allocate the needed space for the demangled symbol. This also fixes a memory leak, which would occur whenever __cxa_demangle() failed. Reported by: pgj PR: base/191981 Modified: stable/10/lib/libproc/proc_sym.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libproc/proc_sym.c ============================================================================== --- stable/10/lib/libproc/proc_sym.c Tue Aug 12 17:51:26 2014 (r269884) +++ stable/10/lib/libproc/proc_sym.c Tue Aug 12 17:56:48 2014 (r269885) @@ -57,21 +57,15 @@ demangle(const char *symbol, char *buf, { #ifndef NO_CXA_DEMANGLE char *dembuf; - size_t demlen; if (symbol[0] == '_' && symbol[1] == 'Z' && symbol[2]) { - dembuf = malloc(len); - if (!dembuf) - goto fail; - demlen = len; - dembuf = __cxa_demangle(symbol, dembuf, &demlen, NULL); + dembuf = __cxa_demangle(symbol, NULL, NULL, NULL); if (!dembuf) goto fail; strlcpy(buf, dembuf, len); free(dembuf); + return; } - - return; fail: #endif /* NO_CXA_DEMANGLE */ strlcpy(buf, symbol, len);