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<wasm_ref_t>`.
This commit is contained in:
Alex Crichton
2020-07-17 14:45:55 -05:00
committed by GitHub
parent c3ff0754d4
commit 3aeab23bf1

View File

@@ -25,7 +25,7 @@ pub union wasm_val_union {
impl Drop for wasm_val_t { impl Drop for wasm_val_t {
fn drop(&mut self) { fn drop(&mut self) {
match into_valtype(self.kind) { match into_valtype(self.kind) {
ValType::ExternRef => unsafe { ValType::FuncRef | ValType::ExternRef => unsafe {
if !self.of.ref_.is_null() { if !self.of.ref_.is_null() {
drop(Box::from_raw(self.of.ref_)); drop(Box::from_raw(self.of.ref_));
} }