Skip to content

Commit

Permalink
Reuse validator allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
chipshort committed Jul 24, 2023
1 parent 524e2d9 commit 1fb845d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/vm/src/static_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@ pub fn validate_wasm<'a>(
..Default::default()
});

let mut fun_allocations = Default::default();
for p in Parser::new(0).parse_all(wasm_code) {
let p = p?;
// validate the payload
if let ValidPayload::Func(fv, body) = validator.payload(&p)? {
// also validate function bodies
fv.into_validator(Default::default()).validate(&body)?;
let mut fun_validator = fv.into_validator(fun_allocations);
fun_validator.validate(&body)?;
fun_allocations = fun_validator.into_allocations();
}
// tell caller about the payload
handle_payload(p)?;
Expand Down

0 comments on commit 1fb845d

Please sign in to comment.