From: Harald Anlauf Date: Sat, 1 Mar 2025 14:42:57 +0000 (+0100) Subject: Fortran: fix front-end memleak after failure during parsing of NULLIFY X-Git-Tag: basepoints/gcc-16~1778 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f7db0263f792466983f53652fb06268767b35305;p=thirdparty%2Fgcc.git Fortran: fix front-end memleak after failure during parsing of NULLIFY gcc/fortran/ChangeLog: * match.cc (gfc_match_nullify): Free matched expression when cleaning up. * primary.cc (match_variable): Initialize result to NULL. --- diff --git a/gcc/fortran/match.cc b/gcc/fortran/match.cc index c3c330520d6..ec9e5873204 100644 --- a/gcc/fortran/match.cc +++ b/gcc/fortran/match.cc @@ -5071,6 +5071,7 @@ cleanup: new_st.expr1 = NULL; gfc_free_expr (new_st.expr2); new_st.expr2 = NULL; + gfc_free_expr (p); return MATCH_ERROR; } diff --git a/gcc/fortran/primary.cc b/gcc/fortran/primary.cc index 8a38720422e..161d4c26964 100644 --- a/gcc/fortran/primary.cc +++ b/gcc/fortran/primary.cc @@ -4298,6 +4298,8 @@ match_variable (gfc_expr **result, int equiv_flag, int host_flag) locus where, old_loc; match m; + *result = NULL; + /* Since nothing has any business being an lvalue in a module specification block, an interface block or a contains section, we force the changed_symbols mechanism to work by setting