https://gcc.gnu.org/g:a82c4dfe52dac332e0a6f1522459d2f8548419bc
commit r15-2917-ga82c4dfe52dac332e0a6f1522459d2f8548419bc Author: Harald Anlauf <anl...@gmx.de> Date: Tue Aug 13 21:17:45 2024 +0200 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. Diff: --- gcc/fortran/simplify.cc | 10 +++++++--- gcc/fortran/target-memory.cc | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc index 8ddd491de113..953d59efd70e 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 a02db7a06e49..0a289f32d373 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;