mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-08 21:58:20 +00:00
fix(c-api) Fix wasm_func_call when params are empty.
`wasm_$name_vec_t.into_slice` returns `None` if the vec is empty. So an empty vec of `wasm_extern_t` given to `wasm_func_call` was raising an error. This patch fixes this.
This commit is contained in:
14
lib/c-api/src/wasm_c_api/externals/function.rs
vendored
14
lib/c-api/src/wasm_c_api/externals/function.rs
vendored
@@ -142,11 +142,15 @@ pub unsafe extern "C" fn wasm_func_call(
|
||||
results: &mut wasm_val_vec_t,
|
||||
) -> Option<Box<wasm_trap_t>> {
|
||||
let params = args
|
||||
.into_slice()?
|
||||
.into_iter()
|
||||
.map(TryInto::try_into)
|
||||
.collect::<Result<Vec<Val>, _>>()
|
||||
.expect("Argument conversion failed");
|
||||
.into_slice()
|
||||
.map(|slice| {
|
||||
slice
|
||||
.into_iter()
|
||||
.map(TryInto::try_into)
|
||||
.collect::<Result<Vec<Val>, _>>()
|
||||
.expect("Argument conversion failed")
|
||||
})
|
||||
.unwrap_or_else(|| Vec::new());
|
||||
|
||||
match func.inner.call(¶ms) {
|
||||
Ok(wasm_results) => {
|
||||
|
||||
Reference in New Issue
Block a user