From patchwork Fri Sep 2 19:19:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 937 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:ecc5:0:0:0:0:0 with SMTP id s5csp871225wro; Fri, 2 Sep 2022 12:20:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR4Jv9NSZPtdovqp5omcGrCuO2oC625HBlYHezZVVmn1METhSwIgjReSJTRK0L4nkZdAgwBK X-Received: by 2002:a05:6402:4498:b0:448:dd50:c22d with SMTP id er24-20020a056402449800b00448dd50c22dmr14940899edb.196.1662146440554; Fri, 02 Sep 2022 12:20:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662146440; cv=none; d=google.com; s=arc-20160816; b=JPAK2j6IgmFAddfjzJbts1uto/KYov2HWhPF14g5zOh4QIATbhcnTU/7oH3X42jbb3 S+oipQCBhHbpMu2ZE24SZGLDj0iaiFqxqXVT/0eF/8kArWsLtJHX25V76QVR+0pnHiiZ wLzEdesHL1pYX4lQ5Bdgrn2Qilvm4FvnjIR8ZTrHDMUeWyj0Nj5yJ78acuV2OLuYuFry 4qoJWca5gLQwrd3k18Ho2vFdomOKNX3TlSgSJT0vJPOB36Fe8FuWcjmqwNrxyDMMcYfu elQ9yP1JVeDV9JQ4caziha1nyRReUQ351uatfIRlO3IH3mZU0zcHejKzK4OAdoLpN6Po opvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:sensitivity :importance:date:subject:to:message-id:mime-version:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=zVWusV/YEXeDvgl+qQ7JaH62NQadsnxIC5imKai4te4=; b=a/SWUGNj6Az0ovFIlRiVo7vsmajgYEobpSSGERlRMuaBEF7VugEVbV9ljYo4M2XD3K eC7/fbLHCXgTiGGAHBiHT3MO+i5FuNtm5bIgcgsIFdBcXMLg00Lm2UaC/bGZAfhYOLEw LbZH5EqQD03iHfgftXRfMHy1cem3jTD6ndL+4vDYqkWDOIEaB0lCbcRWIwc5/p7D5cKt otg/Fz0ZynBoqcH4nxRxE3VRIJng5u8bFCltC2ranaXda8AiG2cCfo3d6pVkwG777bUW cmx3oO5egiVI0eqTToerpD2KHYaf3c9ehthXR88wQ8+svEVtqUiHLk1sc9djptNy/91m y28Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="qKUoUO/q"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id f21-20020a056402195500b0044884a912b2si2427441edz.143.2022.09.02.12.20.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 12:20:40 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="qKUoUO/q"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 52C363858D1E for ; Fri, 2 Sep 2022 19:20:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 52C363858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662146439; bh=zVWusV/YEXeDvgl+qQ7JaH62NQadsnxIC5imKai4te4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=qKUoUO/qUPuQXZkDzl1+Ws0yPNlfaXf2mYNwRsuFbmIFN7uaSEuwmVxjBm3lZkyQl uCSI3lVPFxDNGPHZzjEDqyT/x657Wdt4GVhJ92kX4x/GXBGu6iY2QAbUoBUmmweKEZ TRtSZjes9TEbgpk9xjz6LEycS4iMbTHxD/jfOtTs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by sourceware.org (Postfix) with ESMTPS id 4FA293858D1E; Fri, 2 Sep 2022 19:19:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4FA293858D1E X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [79.251.1.151] ([79.251.1.151]) by web-mail.gmx.net (3c-app-gmx-bs46.server.lan [172.19.170.98]) (via HTTP); Fri, 2 Sep 2022 21:19:53 +0200 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: [PATCH, committed] Fortran: avoid NULL pointer dereference on invalid DATA constant [PR99349] Date: Fri, 2 Sep 2022 21:19:53 +0200 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:35Om98lrQSZDhq3P8VFueFurluDQhQTTljLMvIvAI5YhaXiVvKAr8MZYVnOA8NPBpUkVO hA7Vup8XfX5oc1r6YW3f5D3WcC2jitiiA27dEDS37ws8TyJct4UFzuDMnnBl7C+GVtqyjApqvQ2S oUEJRvM2kdM21O54LNz5mr174iCHzr3bH/W24peSu1nuC4TvO5nkmLWPtOZXx9xCsMmHnCEPGUoc gn7sKKfjgut5m/JxoTkohA/DGBTkOkBUf2COYbnWJlXeK0nOTu0wv0N68+FDjJ/XmSz2gWtSXjsz vQ= X-UI-Out-Filterresults: notjunk:1;V03:K0:okSwuOMXV9Q=:VabwDKOeJrXyrZvB2bIRY0 fpWK8cBlkIgz19zQ069lCGP4Y3fwxuTxTvSP382bipOwUCk0ErKBbjSd3n/w66gYpfF0mH/XY L0mbgdAgBtwVJnNVIGIfkiKhpJA5HP2hqYeBpb63OhxNUqe86/WTfXn85rtRbd0O6tBs+dnip HfbthQinASP+qztd26IJBofFshkargDVRVjmf31RR0a8c/2XPdiz3AS/HNZewUiBh5df3M/Zq zhXMurZFVCNb5ZLvWd4hd4hLvHgyp01dYz1hSNHUj4wpLwXKeREvMVx2frhdiVEZbqyyJ8i3Q HwGgi2/CKnUIGN0pLL4WxXDLEhnrb2A+JLu4I9VeLrb9VYmFMxYg1zMKunx1I21TkIWmMYlOr 37NPh8yRbL03mRFEnHWKTTuUSWEVsF84T/3CDI0iz6K1/CpE0svApLFaO0BYSLEC27bEDgWiS Dw6DmqCoMAePXTN/educKra9LECVhkh3BUj4Ps2OrgXWfs3/dKBzFkN039SYP6I/Vm3590u/N rahX3+j2PK2G+33TeFWu1e/QdbYDTVND2Nqax6nhz/jq6nN6w3iO4VS4nXPLJ+rL8fvPBFeEa oNu1scJHTVBXlocorbTGasZ9z5xb2GpADfWXkCGgvBOCGnrkybiMC5BYPV3rRQV2R2yemMR23 sAXeXUf5z9ecxaiRiQRE1smDlZVe1eCCO2kugnPAkN8oX34ZiIRWUeQ7Tr47fBnuALBqd2yjr 5L8TTzhfZV/yLSaIk35+PbocJj7nHyQeatjxIPs2rL0Dd5hSJUuuEsl/T1I= X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Harald Anlauf via Gcc-patches From: Harald Anlauf Reply-To: Harald Anlauf Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1742886865939195823?= X-GMAIL-MSGID: =?utf-8?q?1742886865939195823?= Dear all, I've committed the attached fix for a NULL pointer dereference as obvious after a discussion with Steve in the PR, and successful regtesting on x86_64-pc-linux-gnu, as r13-2382. See also https://gcc.gnu.org/g:b6aa7d45b502c01f8703c8d2cee2690f9aa8e282 Thanks, Harald From b6aa7d45b502c01f8703c8d2cee2690f9aa8e282 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Fri, 2 Sep 2022 21:07:26 +0200 Subject: [PATCH] Fortran: avoid NULL pointer dereference on invalid DATA constant [PR99349] gcc/fortran/ChangeLog: PR fortran/99349 * decl.cc (match_data_constant): Avoid NULL pointer dereference. gcc/testsuite/ChangeLog: PR fortran/99349 * gfortran.dg/pr99349.f90: New test. Co-authored-by: Steven G. Kargl --- gcc/fortran/decl.cc | 3 ++- gcc/testsuite/gfortran.dg/pr99349.f90 | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/pr99349.f90 diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc index b6400514731..0f9b2ced4c2 100644 --- a/gcc/fortran/decl.cc +++ b/gcc/fortran/decl.cc @@ -423,7 +423,8 @@ match_data_constant (gfc_expr **result) data-pointer-initialization compatible (7.5.4.6) with the initial data target; the data statement object is initially associated with the target. */ - if ((*result)->symtree->n.sym->attr.save + if ((*result)->symtree + && (*result)->symtree->n.sym->attr.save && (*result)->symtree->n.sym->attr.target) return m; gfc_free_expr (*result); diff --git a/gcc/testsuite/gfortran.dg/pr99349.f90 b/gcc/testsuite/gfortran.dg/pr99349.f90 new file mode 100644 index 00000000000..e1f4628af0b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr99349.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +! PR fortran/99349 - ICE in match_data_constant +! Contributed by G.Steinmetz + +function f() + logical, parameter :: a((1.)/0) = .true. ! { dg-error "Parameter array" } + integer :: b + data b /a%kind/ ! { dg-error "Syntax error" } +end -- 2.35.3