diff options
author | Steven G. Kargl <kargl@gcc.gnu.org> | 2018-04-24 23:17:29 +0000 |
---|---|---|
committer | Steven G. Kargl <kargl@gcc.gnu.org> | 2018-04-24 23:17:29 +0000 |
commit | 58da192e7a35ed16e23d5a33246d68fae3d1a1dc (patch) | |
tree | 5fc084040ddbfbf1950f194b1e97005353888bae /gcc/fortran/decl.c | |
parent | 08417efa3ad973ba7b1be5b6a530e0b186e3c294 (diff) | |
download | gcc-58da192e7a35ed16e23d5a33246d68fae3d1a1dc.zip gcc-58da192e7a35ed16e23d5a33246d68fae3d1a1dc.tar.gz gcc-58da192e7a35ed16e23d5a33246d68fae3d1a1dc.tar.bz2 |
re PR fortran/85520 (Out of memory when declaring a character with len << 0)
2018-04-24 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/85520
* decl.c (gfc_match_char_spec): Check for negative length and set to 0.
2018-04-24 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/85520
* gfortran.dg/pr85520.f90: New test.
From-SVN: r259623
Diffstat (limited to 'gcc/fortran/decl.c')
-rw-r--r-- | gcc/fortran/decl.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 192910d..d1b75cc 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -3235,7 +3235,11 @@ done: e = gfc_copy_expr (len); gfc_reduce_init_expr (e); if (e->expr_type == EXPR_CONSTANT) - gfc_replace_expr (len, e); + { + gfc_replace_expr (len, e); + if (mpz_cmp_si (len->value.integer, 0) < 0) + mpz_set_ui (len->value.integer, 0); + } else gfc_free_expr (e); cl->length = len; |