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:
@@ -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_));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user