fuzzbug fix

This commit is contained in:
Chris Fallin 2021-12-24 15:17:38 -08:00
parent c0fd7e8fc8
commit 87c416cadf
3 changed files with 3 additions and 1 deletions

View file

@ -160,7 +160,7 @@ pub fn produce_func_wasm<FT: FuncTypeSink>(
locals: vec![], locals: vec![],
}; };
wasm.locals wasm.locals
.extend(f.locals.iter().map(|ty| ty_to_valty(*ty))); .extend(f.locals.iter().skip(f.n_params).map(|ty| ty_to_valty(*ty)));
wasm.locals wasm.locals
.extend(locations.new_locals.iter().map(|ty| ty_to_valty(*ty))); .extend(locations.new_locals.iter().map(|ty| ty_to_valty(*ty)));

View file

@ -109,6 +109,7 @@ fn parse_body<'a>(
for &param in &module.signatures[my_sig].params[..] { for &param in &module.signatures[my_sig].params[..] {
ret.locals.push(param); ret.locals.push(param);
} }
ret.n_params = module.signatures[my_sig].params.len();
for &r in &module.signatures[my_sig].returns[..] { for &r in &module.signatures[my_sig].returns[..] {
ret.rets.push(r); ret.rets.push(r);
} }

View file

@ -53,6 +53,7 @@ impl FuncDecl {
#[derive(Clone, Debug, Default)] #[derive(Clone, Debug, Default)]
pub struct FunctionBody { pub struct FunctionBody {
pub n_params: usize,
pub rets: Vec<Type>, pub rets: Vec<Type>,
pub locals: Vec<Type>, pub locals: Vec<Type>,
pub blocks: Vec<Block>, pub blocks: Vec<Block>,