Fix self.iterations underflow (#1942)

* fix

* fix

* FMT
This commit is contained in:
Dongjia "toka" Zhang 2024-03-15 19:13:58 +01:00 committed by GitHub
parent e30ff57456
commit c6875b8cf6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -109,7 +109,11 @@ where
manager: &mut EM, manager: &mut EM,
) -> Result<(), Error> { ) -> Result<(), Error> {
start_timer!(state); start_timer!(state);
let num = self.iterations(state)? - self.execs_since_progress_start(state)?;
// Here saturating_sub is needed as self.iterations() might be actually smaller than the previous value before reset.
let num = self
.iterations(state)?
.saturating_sub(self.execs_since_progress_start(state)?);
let mut testcase = state.current_testcase_mut()?; let mut testcase = state.current_testcase_mut()?;
let Ok(input) = I::try_transform_from(&mut testcase, state) else { let Ok(input) = I::try_transform_from(&mut testcase, state) else {

View File

@ -222,7 +222,9 @@ where
} }
(None, None) => { (None, None) => {
// fall back to random // fall back to random
let iters = self.iterations(state)? - self.execs_since_progress_start(state)?; let iters = self
.iterations(state)?
.saturating_sub(self.execs_since_progress_start(state)?);
for _ in 1..=iters { for _ in 1..=iters {
self.perform_mutation(fuzzer, executor, state, manager, &input)?; self.perform_mutation(fuzzer, executor, state, manager, &input)?;
} }