Skip to content

Commit

Permalink
Fix crash when corrupted seq numbers become near 2^32.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirbaio committed Apr 23, 2024
1 parent f121681 commit 3ce370e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ impl<'a> FileSearcher<'a> {
}

async fn really_seek<F: Flash>(&mut self, m: &mut FileManager<F>) -> Result<bool, Error<F::Error>> {
let left = self.left.add(1).unwrap();
let left = self.left.add(1)?;
let mut i = if left >= self.right {
0
} else {
Expand All @@ -1095,7 +1095,7 @@ impl<'a> FileSearcher<'a> {
Err(SearchSeekError::Flash(e)) => return Err(Error::Flash(e)),
Err(SearchSeekError::Corrupted) => corrupted!(),
Err(SearchSeekError::TooMuchLeft) => {
let new_left = seq.add(1).unwrap();
let new_left = seq.add(1)?;
assert!(new_left >= self.left);
self.left = new_left;
}
Expand Down Expand Up @@ -1236,7 +1236,7 @@ impl<'a> FileSearcher<'a> {
}
SeekDirection::Right => {
trace!("search seek right");
self.left = self.curr_high.add(1).unwrap();
self.left = self.curr_high.add(1)?;
self.result = self.curr_mid;
}
}
Expand Down

0 comments on commit 3ce370e

Please sign in to comment.