Skip to content

Commit a953409

Browse files
committed
relaxed debug_assert and add comment
1 parent 5e6754c commit a953409

File tree

1 file changed

+6
-4
lines changed
  • crates/wasmi/src/engine/executor/handler

1 file changed

+6
-4
lines changed

crates/wasmi/src/engine/executor/handler/state.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,16 @@ pub struct Sp {
222222
impl Sp {
223223
pub fn new(cells: &mut Vec<UntypedVal>, start: usize) -> Self {
224224
debug_assert!(
225-
start < cells.len(),
225+
// Note: it is fine to use <= here because for zero sized frames
226+
// we sometimes end up with `start == cells.len()` which isn't
227+
// bad since in those cases `Sp` is never used.
228+
start <= cells.len(),
226229
"start = {}, cells.len() = {}",
227230
start,
228231
cells.len()
229232
);
230-
Self {
231-
value: unsafe { cells.as_mut_ptr().add(start) },
232-
}
233+
let value = unsafe { cells.as_mut_ptr().add(start) };
234+
Self { value }
233235
}
234236

235237
pub fn dangling() -> Self {

0 commit comments

Comments
 (0)