mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-07 05:08:19 +00:00
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:
@@ -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;
|
||||
*traps = Box::into_raw(trap);
|
||||
|
||||
return None;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user