Skip to content

Commit

Permalink
Fix memory.grow bound check
Browse files Browse the repository at this point in the history
  • Loading branch information
kateinoigakukun committed Nov 20, 2023
1 parent 8917643 commit 2395b87
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions crates/vm/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@ impl MemoryInstance {
}

pub fn grow(&mut self, n: usize) -> Result<()> {
let len = self.page_count() + n;
if len > 65536 {
return Err(Error::GrowOverMaximumPageSize(len));
}
let len = self.page_count().checked_add(n).ok_or(Error::GrowOverMaximumPageSize(n))?;

if let Some(max) = self.max {
if len > max {
Expand Down

0 comments on commit 2395b87

Please sign in to comment.