From patchwork Fri Aug 23 09:32:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 269364 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id F38242C0099 for ; Fri, 23 Aug 2013 19:33:03 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=q/Io1hoOUgeoiX8jw TayqKYOGivlUvaBxdVNTR3EUMrMw1Mw2cZqtMpEGA6eu7mgL3AVH+iMEkN/GFfTQ sUjdhzAFauHLxwiMousS9O70DpXiLiZMQFCjld6x7TBR3xihU6qYY4qubI6s8YVV bjAJAyHuwRm97zg2uKAr5i7oh8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=HUIgEksbgM0Wogp4vFKm3r1 01HQ=; b=DTbYusiTxW/YhSytxLneHz59NTNDL7Y0kRAxcbADrIe/shvA6wUVbvi 2zSbDvRiNE/BSfm5mqEKnqkOtv80rMMSnD5ofpo18Nl/oEdk4RdZfE7O+pZQel/A k5I/y4I2inYWb/89jWLOVVQZRWHsDKADKzkGb5k7MvJS18TNqUe4= Received: (qmail 21612 invoked by alias); 23 Aug 2013 09:32:56 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 21603 invoked by uid 89); 23 Aug 2013 09:32:56 -0000 X-Spam-SWARE-Status: No, score=-8.8 required=5.0 tests=AWL, BAYES_00, KHOP_THREADED, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 23 Aug 2013 09:32:56 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r7N9WsHi015528 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 23 Aug 2013 05:32:54 -0400 Received: from oldenburg.str.redhat.com (oldenburg.str.redhat.com [10.33.200.60]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r7N9Wpmn018485 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 23 Aug 2013 05:32:53 -0400 Message-ID: <52172C42.5060701@redhat.com> Date: Fri, 23 Aug 2013 11:32:50 +0200 From: Florian Weimer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130805 Thunderbird/17.0.8 MIME-Version: 1.0 To: Jan Hubicka CC: gcc-patches@gcc.gnu.org Subject: Re: Fix buffer overflow in ipa_profile References: <20130821143034.GA24174@kam.mff.cuni.cz> In-Reply-To: <20130821143034.GA24174@kam.mff.cuni.cz> X-Virus-Found: No On 08/21/2013 04:30 PM, Jan Hubicka wrote: > Index: ipa.c > =================================================================== > --- ipa.c (revision 201890) > +++ ipa.c (working copy) > @@ -1397,7 +1397,7 @@ ipa_profile_read_summary (void) > static unsigned int > ipa_profile (void) > { > - struct cgraph_node **order = XCNEWVEC (struct cgraph_node *, cgraph_n_nodes); > + struct cgraph_node **order; > struct cgraph_edge *e; > int order_pos; > bool something_changed = false; > @@ -1575,6 +1575,7 @@ ipa_profile (void) > nuseless, nuseless * 100.0 / nindirect, > nconverted, nconverted * 100.0 / nindirect); > > + order = XCNEWVEC (struct cgraph_node *, cgraph_n_nodes); > order_pos = ipa_reverse_postorder (order); > for (i = order_pos - 1; i >= 0; i--) > { Shouldn't the definition of order be moved down to the initialization, like in the attached patch? Index: gcc/ipa.c =================================================================== --- gcc/ipa.c (revision 201937) +++ gcc/ipa.c (working copy) @@ -1397,9 +1397,7 @@ static unsigned int ipa_profile (void) { - struct cgraph_node **order; struct cgraph_edge *e; - int order_pos; bool something_changed = false; int i; gcov_type overall_time = 0, cutoff = 0, cumulated = 0, overall_size = 0; @@ -1575,8 +1573,9 @@ nuseless, nuseless * 100.0 / nindirect, nconverted, nconverted * 100.0 / nindirect); - order = XCNEWVEC (struct cgraph_node *, cgraph_n_nodes); - order_pos = ipa_reverse_postorder (order); + struct cgraph_node **order + = XCNEWVEC (struct cgraph_node *, cgraph_n_nodes); + int order_pos = ipa_reverse_postorder (order); for (i = order_pos - 1; i >= 0; i--) { if (order[i]->local.local && cgraph_propagate_frequency (order[i]))