diff options
author | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2008-02-29 22:50:25 +0000 |
---|---|---|
committer | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2008-02-29 22:50:25 +0000 |
commit | 44000dbbe05896777b4781f5c274272c15097861 (patch) | |
tree | 6b8d4f59dabb468ef7b4fe96a4195f38a77e215b /gcc/fortran/expr.c | |
parent | c17ee676e55b86d2c9d61b569a8c7e0cd8fb6d4c (diff) | |
download | gcc-44000dbbe05896777b4781f5c274272c15097861.zip gcc-44000dbbe05896777b4781f5c274272c15097861.tar.gz gcc-44000dbbe05896777b4781f5c274272c15097861.tar.bz2 |
re PR fortran/35059 (Seg fault when max constructor limit reached)
2008-02-29 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/35059
* expr.c (find_array_element): Modify traversing the constructor to
avoid trying to access NULL memory pointed to by next for the
last element. (find_array_section): Exit while loop if cons->next is
NULL.
* trans-expr.c (gfc_conv_scalar_char_value): Initialize gfc_typespec.
(gfc_conv_function_call): Same.
* decl.c (gfc_match_implicit): Same.
* trans-intrinsic.c (gfc_conv_intrinsic_sr_kind): Same.
From-SVN: r132782
Diffstat (limited to 'gcc/fortran/expr.c')
-rw-r--r-- | gcc/fortran/expr.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 0b0fd09..329bc72 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -1051,18 +1051,19 @@ find_array_element (gfc_constructor *cons, gfc_array_ref *ar, mpz_mul (span, span, tmp); } - if (cons) - { - for (nelemen = mpz_get_ui (offset); nelemen > 0; nelemen--) - { - if (cons->iterator) - { - cons = NULL; - goto depart; - } - cons = cons->next; - } - } + for (nelemen = mpz_get_ui (offset); nelemen > 0; nelemen--) + { + if (cons) + { + if (cons->iterator) + { + cons = NULL; + + goto depart; + } + cons = cons->next; + } + } depart: mpz_clear (delta); @@ -1341,7 +1342,7 @@ find_array_section (gfc_expr *expr, gfc_ref *ref) cons = base; } - while (mpz_cmp (ptr, index) > 0) + while (cons && cons->next && mpz_cmp (ptr, index) > 0) { mpz_add_ui (index, index, one); cons = cons->next; |