From 23a37615d29c3033210625046517778f91bb17bb Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Wed, 30 Jul 2025 20:36:01 +0200 Subject: [PATCH] Add a few missing delete to allocated temporaries gcc/rust/ChangeLog: * rust-gcc.cc (array_initializer): Add missing delete Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/rust-gcc.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc index 0f9ccfb9c81a..fbba31cadde3 100644 --- a/gcc/rust/rust-gcc.cc +++ b/gcc/rust/rust-gcc.cc @@ -1433,6 +1433,7 @@ array_initializer (tree fndecl, tree block, tree array_type, tree length, length, true, locus, &t); tree len = tmp_len->get_tree (locus); stmts.push_back (t); + delete tmp_len; // Temporary variable for pointer used to initialize elements. tree ptr_type = pointer_type (TREE_TYPE (array_type)); @@ -1443,6 +1444,7 @@ array_initializer (tree fndecl, tree block, tree array_type, tree length, = temporary_variable (fndecl, block, ptr_type, ptr_init, false, locus, &t); tree ptr = tmp_ptr->get_tree (locus); stmts.push_back (t); + delete tmp_ptr; // push statement list for the loop std::vector loop_stmts; @@ -1479,6 +1481,7 @@ array_initializer (tree fndecl, tree block, tree array_type, tree length, // Return the temporary in the provided pointer and the statement list which // initializes it. *tmp = tmp_array->get_tree (locus); + delete tmp_array; return statement_list (stmts); }