From patchwork Mon Mar 25 11:59:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John David Anglin X-Patchwork-Id: 1064210 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-498374-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bell.net Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="HJd7YrGi"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44SXrH0b8Wz9sSd for ; Mon, 25 Mar 2019 22:59:58 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=Iuc6hInRNGigRe/q LJgF6bg36FihIUOSe8r6i6YkKVMSwZFsdI0EQuyxWIdMLAC1m1ytWZZGsw1Ut29p seL0xyFe607gFic/GruU5TGq3GT2yY8z06AKf+TquyHc1yGjOCJCG5NTU8fe9l+d 9wVG4uWNx3cRU99wWUbCUrVv6Sw= 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:to :from:subject:message-id:date:mime-version:content-type :content-transfer-encoding; s=default; bh=jCSjVBmqnvWUxfKHQLXtFe 78h74=; b=HJd7YrGi+LATShghO+ZbfFkquRzTi/JFxYQOtTwif19icj+RVFV5a5 VqL2ulBIM6Ioxvslhefo1HHgr7jf5ug25IGqZDptcCo1DaK8/qz3pVUC+xsWfKQ2 X3XSu6bL1gRSjQhotMTsa0OeMxG1GBkZm36Jspb5J06fmuWzRwEsI= Received: (qmail 77981 invoked by alias); 25 Mar 2019 11:59:50 -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 77971 invoked by uid 89); 25 Mar 2019 11:59:49 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, SPF_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 spammy=100000000, H*r:192.168.2 X-HELO: torfep01.bell.net Received: from simcoe207srvr.owm.bell.net (HELO torfep01.bell.net) (184.150.200.207) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 25 Mar 2019 11:59:48 +0000 Received: from bell.net torfep01 184.150.200.158 by torfep01.bell.net with ESMTP id <20190325115946.CQPA4584.torfep01.bell.net@torspm01.bell.net> for ; Mon, 25 Mar 2019 07:59:46 -0400 Received: from [192.168.2.49] (really [70.53.52.226]) by torspm01.bell.net with ESMTP id <20190325115946.JNCG39285.torspm01.bell.net@[192.168.2.49]>; Mon, 25 Mar 2019 07:59:46 -0400 To: GCC Patches From: John David Anglin Subject: [committed] Fix PR libgfortran/79540 Openpgp: preference=signencrypt Message-ID: <77487ad6-1434-28aa-ad4f-dd25e44ac86f@bell.net> Date: Mon, 25 Mar 2019 07:59:46 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.0 MIME-Version: 1.0 X-CM-Analysis: v=2.3 cv=bPxo382Z c=1 sm=1 tr=0 a=eekNWfHKKKZHbRJeTMr8Cw==:117 a=eekNWfHKKKZHbRJeTMr8Cw==:17 a=IkcTkHD0fZMA:10 a=NTGMnVQrEZIA:10 a=FBHGMhGWAAAA:8 a=2zsTArx8Hmi0c9pnbg0A:9 a=QEXdDO2ut3YA:10 a=9gvnlMMaQFpL9xblJ6ne:22 X-CM-Envelope: MS4wfACyvGEriGYH6HU7pknu/hGjr/GenelX90ie1YmRR/Njr6rQSWQCd7y1iKRVOuBAA6lJzuVgNXN1sCgpfBloaqG36fsvNVsfWcC7O1pjfPv+0+03YDkw fjO/I30BWRnzuIcpu6dZc5/BhOvpBms+QGnuIVNiEEmxtsiQnStRm9qj90fsfcXgmKEbzX4Fw8lLyw== With the following fortran format from the gfortran.dg/fmt_fw_d.f90 test print '(f2.1)', 100.000000 end The computed number of digits is negative. On hppa-hpux, this causes a stack overflow in memcpy. The attached change skips the copy when ndigits is not positive. We also only fill put with nulls when i in non negative. This fixes the testcase with no regressions. Committed to trunk. Dave Index: io/write_float.def =================================================================== --- io/write_float.def (revision 269890) +++ io/write_float.def (working copy) @@ -620,7 +620,7 @@ } /* Set digits after the decimal point, padding with zeros. */ - if (nafter > 0) + if (ndigits >= 0 && nafter > 0) { if (nafter > ndigits) i = ndigits; @@ -627,7 +627,8 @@ else i = nafter; - memcpy (put, digits, i); + if (i > 0) + memcpy (put, digits, i); while (i < nafter) put[i++] = '0';