From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5072 invoked by alias); 10 May 2014 19:14:02 -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 5045 invoked by uid 89); 10 May 2014 19:14:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mail-gw1-out.broadcom.com Received: from mail-gw1-out.broadcom.com (HELO mail-gw1-out.broadcom.com) (216.31.210.62) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 10 May 2014 19:13:58 +0000 Received: from irvexchcas08.broadcom.com (HELO IRVEXCHCAS08.corp.ad.broadcom.com) ([10.9.208.57]) by mail-gw1-out.broadcom.com with ESMTP; 10 May 2014 13:30:22 -0700 Received: from IRVEXCHSMTP1.corp.ad.broadcom.com (10.9.207.51) by IRVEXCHCAS08.corp.ad.broadcom.com (10.9.208.57) with Microsoft SMTP Server (TLS) id 14.3.174.1; Sat, 10 May 2014 12:13:56 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP1.corp.ad.broadcom.com (10.9.207.51) with Microsoft SMTP Server id 14.3.174.1; Sat, 10 May 2014 12:13:56 -0700 Received: from [10.177.252.86] (unknown [10.177.252.86]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id A6E145D818; Sat, 10 May 2014 12:13:55 -0700 (PDT) Message-ID: <536E7A72.1040203@broadcom.com> Date: Sat, 10 May 2014 19:14:00 -0000 From: Andrew Burgess User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: Ian Lance Taylor CC: gcc-patches , Jason Merrill , Subject: Re: [PATCH] cplus-demangler, free resource after a failed call to gnu_special. References: <1399646123-9960-1-git-send-email-aburgess@broadcom.com> In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2014-05/txt/msg00678.txt.bz2 On 09/05/2014 9:53 PM, Ian Lance Taylor wrote: > On Fri, May 9, 2014 at 7:35 AM, 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. Could you let me know if this is enough, or give me more details on where you think the problem is as I'm missing it :) Thanks for taking a look at this. Andrew