diff options
author | Bernhard Reutner-Fischer <aldot@gcc.gnu.org> | 2023-05-07 00:02:21 +0200 |
---|---|---|
committer | Bernhard Reutner-Fischer <aldot@gcc.gnu.org> | 2023-05-08 07:55:28 +0200 |
commit | 2521390dd2f8e554ecccb380e0efd7aa21cd4b5f (patch) | |
tree | 19d185f6a89b222fe7921ae2c153c1a0a4da0f69 /gcc/fortran/expr.cc | |
parent | d46b3db4bd016a3eccfb933c81c7a9d87c0ad403 (diff) | |
download | gcc-2521390dd2f8e554ecccb380e0efd7aa21cd4b5f.zip gcc-2521390dd2f8e554ecccb380e0efd7aa21cd4b5f.tar.gz gcc-2521390dd2f8e554ecccb380e0efd7aa21cd4b5f.tar.bz2 |
Fortran: Fix mpz and mpfr memory leaks [PR fortran/68800]
gcc/fortran/ChangeLog:
PR fortran/68800
* expr.cc (find_array_section): Fix mpz memory leak.
* simplify.cc (gfc_simplify_reshape): Fix mpz memory leaks in
error paths.
Diffstat (limited to 'gcc/fortran/expr.cc')
-rw-r--r-- | gcc/fortran/expr.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc index b19e364..d91722e 100644 --- a/gcc/fortran/expr.cc +++ b/gcc/fortran/expr.cc @@ -1539,6 +1539,7 @@ find_array_section (gfc_expr *expr, gfc_ref *ref) mpz_init_set_ui (delta_mpz, one); mpz_init_set_ui (nelts, one); mpz_init (tmp_mpz); + mpz_init (ptr); /* Do the initialization now, so that we can cleanup without keeping track of where we were. */ @@ -1682,7 +1683,6 @@ find_array_section (gfc_expr *expr, gfc_ref *ref) mpz_mul (delta_mpz, delta_mpz, tmp_mpz); } - mpz_init (ptr); cons = gfc_constructor_first (base); /* Now clock through the array reference, calculating the index in @@ -1735,7 +1735,8 @@ find_array_section (gfc_expr *expr, gfc_ref *ref) "at %L requires an increase of the allowed %d " "upper limit. See %<-fmax-array-constructor%> " "option", &expr->where, flag_max_array_constructor); - return false; + t = false; + goto cleanup; } cons = gfc_constructor_lookup (base, limit); @@ -1750,8 +1751,6 @@ find_array_section (gfc_expr *expr, gfc_ref *ref) gfc_copy_expr (cons->expr), NULL); } - mpz_clear (ptr); - cleanup: mpz_clear (delta_mpz); @@ -1765,6 +1764,7 @@ cleanup: mpz_clear (ctr[d]); mpz_clear (stride[d]); } + mpz_clear (ptr); gfc_constructor_free (base); return t; } |