From d6975d4b72780a63534f78454c15369fc06d616e Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 17 Jul 2020 11:38:28 -0700 Subject: [PATCH] Fix leaking funcrefs in the C API 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_)); }