Browse Source

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>`.
pull/1960/head
Alex Crichton 4 years ago
committed by GitHub
parent
commit
3aeab23bf1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      crates/c-api/src/val.rs

2
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_));
}

Loading…
Cancel
Save