diff --git a/src/stack_limiter/max_height.rs b/src/stack_limiter/max_height.rs index 4be939b..9e4d945 100644 --- a/src/stack_limiter/max_height.rs +++ b/src/stack_limiter/max_height.rs @@ -147,7 +147,6 @@ pub fn compute(func_idx: u32, module: &elements::Module) -> Result Result= instructions.elements().len() { - break - } - - // If current value stack is higher than maximal height observed so far, - // save the new height. - // However, we don't increase maximal value in unreachable code. - if stack.height() > max_height && !stack.frame(0)?.is_polymorphic { - max_height = stack.height(); - } - - let opcode = &instructions.elements()[pc]; + for opcode in instructions.elements() { match opcode { Nop => {}, @@ -403,7 +390,13 @@ pub fn compute(func_idx: u32, module: &elements::Module) -> Result max_height && !stack.frame(0)?.is_polymorphic { + max_height = stack.height(); + } } Ok(max_height) diff --git a/src/stack_limiter/mod.rs b/src/stack_limiter/mod.rs index 99f13ae..e207467 100644 --- a/src/stack_limiter/mod.rs +++ b/src/stack_limiter/mod.rs @@ -181,8 +181,19 @@ fn compute_stack_cost(func_idx: u32, module: &elements::Module) -> Result Result