* [PATCH, committed] Fortran: avoid NULL pointer dereference on invalid DATA constant [PR99349]
@ 2022-09-02 19:19 Harald Anlauf
0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2022-09-02 19:19 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 279 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: pr99349.diff --]
[-- Type: text/x-patch, Size: 1818 bytes --]
From b6aa7d45b502c01f8703c8d2cee2690f9aa8e282 Mon Sep 17 00:00:00 2001
From: Harald Anlauf <anlauf@gmx.de>
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 <kargl@gcc.gnu.org>
---
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-09-02 19:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-02 19:19 [PATCH, committed] Fortran: avoid NULL pointer dereference on invalid DATA constant [PR99349] Harald Anlauf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).