fix(c-api) wasm_trap_t** in wasm_instance_new does not represent an array.

The `wasm_trap_t**` argument of `wasm_instance_new` represents an
output pointer to a `wasm_trap_t*`, not an array of
`wasm_trap_t*`. This patch updates the code accordingly.
This commit is contained in:
Ivan Enderlin
2020-10-30 09:34:37 +01:00
parent 4102dcb9ac
commit 9583a91678

View File

@@ -41,19 +41,8 @@ pub unsafe extern "C" fn wasm_instance_new(
}
Err(InstantiationError::Start(runtime_error)) => {
let pointer = {
let trap: Box<wasm_trap_t> = Box::new(runtime_error.into());
let mut traps: Vec<*mut wasm_trap_t> = Vec::with_capacity(1);
traps.push(Box::into_raw(trap));
traps.shrink_to_fit();
let pointer = traps.as_mut_ptr();
mem::forget(traps);
pointer
};
*traps = *pointer;
let trap: Box<wasm_trap_t> = Box::new(runtime_error.into());
*traps = Box::into_raw(trap);
return None;
}