Skip to content

Commit

Permalink
Fix leaking funcrefs in the C API (#2040)
Browse files Browse the repository at this point in the history
This commit adds a case to the destructor of `wasm_val_t` to be sure to
deallocate the `Box<wasm_ref_t>`.
  • Loading branch information
alexcrichton authored Jul 17, 2020
1 parent c3ff075 commit 3aeab23
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crates/c-api/src/val.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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_));
}
Expand Down

0 comments on commit 3aeab23

Please sign in to comment.