From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27225 invoked by alias); 12 May 2014 05:40:26 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 27203 invoked by uid 89); 12 May 2014 05:40:25 -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,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ob0-f171.google.com Received: from mail-ob0-f171.google.com (HELO mail-ob0-f171.google.com) (209.85.214.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 12 May 2014 05:40:24 +0000 Received: by mail-ob0-f171.google.com with SMTP id wn1so7566894obc.2 for ; Sun, 11 May 2014 22:40:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=q/juOAYl8KIIXCK0Q6x0I1WvaYJQiyP7H7BQE/iWoYY=; b=MfPrBAFHvVZfLSzazaciPXwO872tIWixVuLnEmsHt+qgMEqqWw8AX5eH7W6RakUf3f DmCCfeex1gHr9hzR14p5JrdqeZbIRD2WHWPWNtucRYA12CLGj/MtKxA6o/JWX1MJKzcd 13c0iMnPRa2/00D2d1NHt6Q0M9HQmvEpIFxlnlHW9u22naIXIaexOZmellCDuHrOuwqd +i0ZvXnRT2sv3AC98YGlGqiNtgCdvucdHPwU8x9fL0R+jn4FVh0YKvFaqVKYnwOwpDUP SHksNrUXuCO19ted7hVvcCVvr4I0nDI7bqnIJB9hjnowHJDkEFweww+XX/G1YCDhGZyS yq8A== X-Gm-Message-State: ALoCoQnvRjyOaT3I0l7FlQAgdFJtwd+BJmXNgPXbHYMtPsE0kQ8Nc20lbGxDFFWIa0riktUxPk0o MIME-Version: 1.0 X-Received: by 10.182.165.134 with SMTP id yy6mr30139189obb.5.1399873222175; Sun, 11 May 2014 22:40:22 -0700 (PDT) Received: by 10.60.118.39 with HTTP; Sun, 11 May 2014 22:40:22 -0700 (PDT) In-Reply-To: <536E7A72.1040203@broadcom.com> References: <1399646123-9960-1-git-send-email-aburgess@broadcom.com> <536E7A72.1040203@broadcom.com> Date: Mon, 12 May 2014 05:40:00 -0000 Message-ID: Subject: Re: [PATCH] cplus-demangler, free resource after a failed call to gnu_special. From: Ian Lance Taylor To: Andrew Burgess Cc: gcc-patches , Jason Merrill , gdb-patches@sourceware.org Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2014-05/txt/msg00131.txt.bz2 On Sat, May 10, 2014 at 12:13 PM, Andrew Burgess wrote: > 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. Right, sorry for the noise. This patch is OK. Thanks. Ian