From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27246 invoked by alias); 14 May 2014 09:01:33 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 27235 invoked by uid 89); 14 May 2014 09:01:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 14 May 2014 09:01:29 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4E91RKA019455 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 May 2014 05:01:27 -0400 Received: from blade.nx (ovpn-116-68.ams2.redhat.com [10.36.116.68]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s4E91Q2Y023434; Wed, 14 May 2014 05:01:26 -0400 Received: by blade.nx (Postfix, from userid 1000) id 3783226234A; Wed, 14 May 2014 10:01:25 +0100 (BST) Date: Wed, 14 May 2014 09:01:00 -0000 From: Gary Benson To: Ian Lance Taylor Cc: Andrew Burgess , gcc-patches , Jason Merrill , gdb-patches@sourceware.org Subject: Re: [PATCH] cplus-demangler, free resource after a failed call to gnu_special. Message-ID: <20140514090125.GA4974@blade.nx> References: <1399646123-9960-1-git-send-email-aburgess@broadcom.com> <536E7A72.1040203@broadcom.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-IsSubscribed: yes X-SW-Source: 2014-05/txt/msg01051.txt.bz2 Ian Lance Taylor wrote: > Andrew Burgess wrote: > > On 09/05/2014 9:53 PM, Ian Lance Taylor wrote: > > > Andrew Burgess wrote: > > > > if ((AUTO_DEMANGLING || GNU_DEMANGLING)) > > > > { > > > > success = gnu_special (work, &mangled, &decl); > > > > + if (!success) > > > > + { > > > > + delete_work_stuff (work); > > > > + string_delete (&decl); > > > > + } > > > > > > As far as I can see, decl may be uninitialized at this point. I > > > don't think you can call string_delete. You need to ensure that > > > decl is initialized somehow. > > > > There's a call to string_init on decl about 10 lines above the > > above diff, just outside of context, but it's unconditional, so > > I figured that would be enough. > > > > Also, if gnu_special returns false, and the call to > > demangle_prefix returns false then we call (near the bottom of > > internal_cplus_demangle) mop_up, which calls string_delete. > > > > Given that decl is initialised once, assuming that the string is > > only released using delete_string then the internal state will > > have been reset back to NULL, so calling delete_string should be > > safe again. > > Right, sorry for the noise. > > This patch is OK. Andrew, would you like me to commit this? Thanks, Gary -- http://gbenson.net/