Skip to content

Commit

Permalink
fix(interpreter): avoid overflow when checking if mem limit reached (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
grandizzy committed May 17, 2024
1 parent 7046d5e commit 05f3c5b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crates/interpreter/src/interpreter/shared_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl SharedMemory {
#[cfg(feature = "memory_limit")]
#[inline]
pub fn limit_reached(&self, new_size: usize) -> bool {
(self.last_checkpoint + new_size) as u64 > self.memory_limit
self.last_checkpoint.saturating_add(new_size) as u64 > self.memory_limit
}

/// Prepares the shared memory for a new context.
Expand Down

0 comments on commit 05f3c5b

Please sign in to comment.