This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[Committed] PR fortran/86110 -- Avoid NULL pointer dereference
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Wed, 13 Jun 2018 12:43:48 -0700
- Subject: [Committed] PR fortran/86110 -- Avoid NULL pointer dereference
- Reply-to: sgk at troutmask dot apl dot washington dot edu
Committed as obviously.
2018-06-13 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/86110
* array.c (gfc_resolve_character_array_constructor): Avoid NULL
pointer dereference.
2018-06-13 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/86110
* gfortran.dg/pr86110.f90: New test.
--
Steve
Index: gcc/fortran/array.c
===================================================================
--- gcc/fortran/array.c (revision 261521)
+++ gcc/fortran/array.c (working copy)
@@ -2040,7 +2040,9 @@ got_charlen:
gfc_ref *ref;
for (ref = p->expr->ref; ref; ref = ref->next)
if (ref->type == REF_SUBSTRING
+ && ref->u.ss.start
&& ref->u.ss.start->expr_type == EXPR_CONSTANT
+ && ref->u.ss.end
&& ref->u.ss.end->expr_type == EXPR_CONSTANT)
break;
Index: gcc/testsuite/gfortran.dg/pr86110.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr86110.f90 (nonexistent)
+++ gcc/testsuite/gfortran.dg/pr86110.f90 (working copy)
@@ -0,0 +1,7 @@
+! { dg-do compile }
+! PR fortran/86110
+program p
+ character(:), allocatable :: x, y
+ x = 'abc'
+ y = [x(:)] ! { dg-error "Incompatible ranks 0 and 1" }
+end