From c36641b89c3f9b17b3abdcb8692689c69ede8fa9 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 28 Feb 2024 10:27:47 -0800 Subject: [PATCH] Fix a memory leak found in fuzzing This fixes a mistake introduced in #7996 where a `global.get` used to initialize a table did not properly drop previous items in the table causing them to leak as the reference count was not decremented. --- crates/runtime/src/table.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/runtime/src/table.rs b/crates/runtime/src/table.rs index 804a2e174ee4..961eee0ec9d1 100644 --- a/crates/runtime/src/table.rs +++ b/crates/runtime/src/table.rs @@ -321,9 +321,7 @@ impl Table { for (item, slot) in items.zip(elements) { debug_assert!(ty.matches(&item)); - unsafe { - *slot = item.into_table_value(); - } + Self::set_raw(ty, slot, item); } Ok(()) }