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:
Ivan Enderlin
2020-10-12 12:20:29 +02:00
parent fea156defa
commit 202ffe7771

View File

@@ -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(&params) {
Ok(wasm_results) => {