This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Committed] PR fortran/86110 -- Avoid NULL pointer dereference


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]