From 3aeab23bf175a6298c01d59273e4d11d290cd7ed Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 17 Jul 2020 14:45:55 -0500 Subject: [PATCH] Fix leaking funcrefs in the C API (#2040) This commit adds a case to the destructor of `wasm_val_t` to be sure to deallocate the `Box`. --- crates/c-api/src/val.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/c-api/src/val.rs b/crates/c-api/src/val.rs index 243df313f39d..4c7777dd1346 100644 --- a/crates/c-api/src/val.rs +++ b/crates/c-api/src/val.rs @@ -25,7 +25,7 @@ pub union wasm_val_union { impl Drop for wasm_val_t { fn drop(&mut self) { match into_valtype(self.kind) { - ValType::ExternRef => unsafe { + ValType::FuncRef | ValType::ExternRef => unsafe { if !self.of.ref_.is_null() { drop(Box::from_raw(self.of.ref_)); }