aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/simplify.cc
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <aldot@gcc.gnu.org>2023-05-07 00:02:21 +0200
committerBernhard Reutner-Fischer <aldot@gcc.gnu.org>2023-05-08 07:55:28 +0200
commit2521390dd2f8e554ecccb380e0efd7aa21cd4b5f (patch)
tree19d185f6a89b222fe7921ae2c153c1a0a4da0f69 /gcc/fortran/simplify.cc
parentd46b3db4bd016a3eccfb933c81c7a9d87c0ad403 (diff)
downloadgcc-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/simplify.cc')
-rw-r--r--gcc/fortran/simplify.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc
index 7b06421..a7b4784 100644
--- a/gcc/fortran/simplify.cc
+++ b/gcc/fortran/simplify.cc
@@ -6866,6 +6866,7 @@ gfc_simplify_reshape (gfc_expr *source, gfc_expr *shape_exp,
gfc_error ("The SHAPE array for the RESHAPE intrinsic at %L has a "
"negative value %d for dimension %d",
&shape_exp->where, shape[rank], rank+1);
+ mpz_clear (index);
return &gfc_bad_expr;
}
@@ -6889,6 +6890,7 @@ gfc_simplify_reshape (gfc_expr *source, gfc_expr *shape_exp,
{
gfc_error ("Shapes of ORDER at %L and SHAPE at %L are different",
&order_exp->where, &shape_exp->where);
+ mpz_clear (index);
return &gfc_bad_expr;
}
@@ -6902,6 +6904,7 @@ gfc_simplify_reshape (gfc_expr *source, gfc_expr *shape_exp,
{
gfc_error ("Sizes of ORDER at %L and SHAPE at %L are different",
&order_exp->where, &shape_exp->where);
+ mpz_clear (index);
return &gfc_bad_expr;
}
@@ -6918,6 +6921,7 @@ gfc_simplify_reshape (gfc_expr *source, gfc_expr *shape_exp,
"in the range [1, ..., %d] for the RESHAPE intrinsic "
"near %L", order[i], &order_exp->where, rank,
&shape_exp->where);
+ mpz_clear (index);
return &gfc_bad_expr;
}
@@ -6926,6 +6930,7 @@ gfc_simplify_reshape (gfc_expr *source, gfc_expr *shape_exp,
{
gfc_error ("ORDER at %L is not a permutation of the size of "
"SHAPE at %L", &order_exp->where, &shape_exp->where);
+ mpz_clear (index);
return &gfc_bad_expr;
}
x[order[i]] = 1;