[gcc r15-7775] Fortran: fix front-end memleak after failure during parsing of NULLIFY
Harald Anlauf
anlauf@gcc.gnu.org
Sat Mar 1 19:13:28 GMT 2025
https://gcc.gnu.org/g:f7db0263f792466983f53652fb06268767b35305
commit r15-7775-gf7db0263f792466983f53652fb06268767b35305
Author: Harald Anlauf <anlauf@gmx.de>
Date: Sat Mar 1 15:42:57 2025 +0100
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:
---
gcc/fortran/match.cc | 1 +
gcc/fortran/primary.cc | 2 ++
2 files changed, 3 insertions(+)
diff --git a/gcc/fortran/match.cc b/gcc/fortran/match.cc
index c3c330520d6f..ec9e5873204a 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 8a38720422ec..161d4c269648 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
More information about the Gcc-cvs
mailing list