Fix another UBSAN in Fortran coarray.
authorMartin Liska <mliska@suse.cz>
Thu, 24 Oct 2019 08:49:02 +0000 (10:49 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Thu, 24 Oct 2019 08:49:02 +0000 (08:49 +0000)
2019-10-24  Martin Liska  <mliska@suse.cz>

PR fortran/92174
* array.c (gfc_resolve_array_spec): Break the loop
for out of bounds index.
* resolve.c (is_non_constant_shape_array): Likewise.

From-SVN: r277367

gcc/fortran/ChangeLog
gcc/fortran/array.c
gcc/fortran/resolve.c

index 5bb04d7..4e39102 100644 (file)
@@ -1,3 +1,10 @@
+2019-10-24  Martin Liska  <mliska@suse.cz>
+
+       PR fortran/92174
+       * array.c (gfc_resolve_array_spec): Break the loop
+       for out of bounds index.
+       * resolve.c (is_non_constant_shape_array): Likewise.
+
 2019-10-23  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        dump-parse-tree.c (show_expr): Add dumping of BT_BOZ constants.
index f0980dd..36223d2 100644 (file)
@@ -410,6 +410,9 @@ gfc_resolve_array_spec (gfc_array_spec *as, int check_constant)
 
   for (i = 0; i < as->rank + as->corank; i++)
     {
+      if (i == GFC_MAX_DIMENSIONS)
+       return false;
+
       e = as->lower[i];
       if (!resolve_array_bound (e, check_constant))
        return false;
index 93f2d0a..5deeb4f 100644 (file)
@@ -12266,6 +12266,9 @@ is_non_constant_shape_array (gfc_symbol *sym)
         simplification now.  */
       for (i = 0; i < sym->as->rank + sym->as->corank; i++)
        {
+         if (i == GFC_MAX_DIMENSIONS)
+           break;
+
          e = sym->as->lower[i];
          if (e && (!resolve_index_expr(e)
                    || !gfc_is_constant_expr (e)))