wasm_interp: ensure WASI argv[0] is the .wasm executable

This commit is contained in:
Brian Carroll 2022-12-05 21:45:18 +00:00
parent aa76634751
commit dfbee7b916
No known key found for this signature in database
GPG key ID: 5C7B2EC4101703C0
2 changed files with 13 additions and 8 deletions

View file

@ -153,7 +153,11 @@ impl<'a, I: ImportDispatcher> Instance<'a, I> {
) -> Result<Option<Value>, String> {
let arg_type_bytes = self.prepare_to_call_export(module, fn_name)?;
for (value_str, type_byte) in arg_strings.into_iter().zip(arg_type_bytes.iter().copied()) {
for (value_str, type_byte) in arg_strings
.into_iter()
.skip(1) // first string is the .wasm filename
.zip(arg_type_bytes.iter().copied())
{
use ValueType::*;
let value = match ValueType::from(type_byte) {
I32 => Value::I32(value_str.parse::<i32>().map_err(|e| e.to_string())?),