]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fortran: fix front-end memleak after failure during parsing of NULLIFY
authorHarald Anlauf <anlauf@gmx.de>
Sat, 1 Mar 2025 14:42:57 +0000 (15:42 +0100)
committerHarald Anlauf <anlauf@gmx.de>
Sat, 1 Mar 2025 19:12:41 +0000 (20:12 +0100)
gcc/fortran/ChangeLog:

* match.cc (gfc_match_nullify): Free matched expression when
cleaning up.
* primary.cc (match_variable): Initialize result to NULL.

gcc/fortran/match.cc
gcc/fortran/primary.cc

index c3c330520d6f2ddee51aa9a3a2bbe80938f9fa27..ec9e5873204a654bb60b6cb4de45499dfbdb6c05 100644 (file)
@@ -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;
 }
 
index 8a38720422ec98c5754ebb924e85c925ca5c67c4..161d4c269648053e7017b09932410cd416f5c88c 100644 (file)
@@ -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