Skip to content

Commit

Permalink
The get_page_indices function requires that length cannot be 0 (#420) (
Browse files Browse the repository at this point in the history
  • Loading branch information
mohanson committed Mar 19, 2024
1 parent 49ef291 commit 219a150
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/snapshot2.rs
Expand Up @@ -263,6 +263,9 @@ impl<I: Clone + PartialEq, D: DataSource<I>> Snapshot2Context<I, D> {
start: u64,
length: u64,
) -> Result<(), Error> {
if length == 0 {
return Ok(());
}
let page_indices = get_page_indices(start, length)?;
for page in page_indices.0..=page_indices.1 {
machine.memory_mut().set_flag(page, FLAG_DIRTY)?;
Expand Down
6 changes: 3 additions & 3 deletions tests/test_resume2.rs
Expand Up @@ -649,13 +649,13 @@ pub fn test_store_bytes_twice() {
}
_ => unimplemented!(),
}
let a = machine.full_memory().unwrap()[4096 * 2];
let mem1 = machine.full_memory().unwrap();

let snapshot = machine.snapshot().unwrap();
let mut machine2 = MachineTy::Asm.build(data_source.clone(), VERSION2);
machine2.resume(snapshot).unwrap();
machine2.set_max_cycles(u64::MAX);
let b = machine2.full_memory().unwrap()[4096 * 2];
let mem2 = machine2.full_memory().unwrap();

assert_eq!(a, b);
assert_eq!(mem1, mem2);
}

0 comments on commit 219a150

Please sign in to comment.