diff --git a/crates/fuzzing/src/generators/stacks.rs b/crates/fuzzing/src/generators/stacks.rs index ffb95158e3..8b5544d003 100644 --- a/crates/fuzzing/src/generators/stacks.rs +++ b/crates/fuzzing/src/generators/stacks.rs @@ -11,6 +11,7 @@ use arbitrary::{Arbitrary, Result, Unstructured}; use wasm_encoder::Instruction; const MAX_FUNCS: usize = 20; +const MAX_OPS: usize = 1_000; /// Generate a Wasm module that keeps track of its current call stack, to /// compare to the host. @@ -50,7 +51,10 @@ impl Stacks { let mut work_list = vec![0]; while let Some(f) = work_list.pop() { - let mut ops = u.arbitrary::>()?; + let mut ops = Vec::with_capacity(u.arbitrary_len::()?.min(MAX_OPS)); + for _ in 0..ops.capacity() { + ops.push(u.arbitrary()?); + } for op in &mut ops { match op { Op::CallThroughHost(idx) | Op::Call(idx) => {