aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2024-08-13 21:17:45 +0200
committerHarald Anlauf <anlauf@gmx.de>2024-08-14 18:37:04 +0200
commita82c4dfe52dac332e0a6f1522459d2f8548419bc (patch)
treeda67d05562f1cd95b5408e6a67fae81f629881d0
parentedb2712936368e803fd67aa520323054b2a5c5e7 (diff)
downloadgcc-a82c4dfe52dac332e0a6f1522459d2f8548419bc.zip
gcc-a82c4dfe52dac332e0a6f1522459d2f8548419bc.tar.gz
gcc-a82c4dfe52dac332e0a6f1522459d2f8548419bc.tar.bz2
Fortran: fix minor frontend GMP leaks
gcc/fortran/ChangeLog: * simplify.cc (gfc_simplify_sizeof): Clear used gmp variable. * target-memory.cc (gfc_target_expr_size): Likewise.
-rw-r--r--gcc/fortran/simplify.cc10
-rw-r--r--gcc/fortran/target-memory.cc2
2 files changed, 9 insertions, 3 deletions
diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc
index 8ddd491..953d59e 100644
--- a/gcc/fortran/simplify.cc
+++ b/gcc/fortran/simplify.cc
@@ -7778,9 +7778,13 @@ gfc_simplify_sizeof (gfc_expr *x)
|| x->ts.u.cl->length->expr_type != EXPR_CONSTANT))
return NULL;
- if (x->rank && x->expr_type != EXPR_ARRAY
- && !gfc_array_size (x, &array_size))
- return NULL;
+ if (x->rank && x->expr_type != EXPR_ARRAY)
+ {
+ if (!gfc_array_size (x, &array_size))
+ return NULL;
+
+ mpz_clear (array_size);
+ }
result = gfc_get_constant_expr (BT_INTEGER, gfc_index_integer_kind,
&x->where);
diff --git a/gcc/fortran/target-memory.cc b/gcc/fortran/target-memory.cc
index a02db7a..0a289f3 100644
--- a/gcc/fortran/target-memory.cc
+++ b/gcc/fortran/target-memory.cc
@@ -158,6 +158,8 @@ gfc_target_expr_size (gfc_expr *e, size_t *size)
asz = mpz_get_ui (tmp);
else
return false;
+
+ mpz_clear (tmp);
}
else
asz = 1;