From f3a4f4f664a80f6278d503c9e9fdd3c85868ab63 Mon Sep 17 00:00:00 2001 From: lenawanel <115283664+lenawanel@users.noreply.github.com> Date: Tue, 29 Aug 2023 13:30:29 +0200 Subject: [PATCH] Remove unneeded loop in `SpliceMutator::mutate` (#1471) previously we searched for the first and the last difference between exactly the same 2 inputs 3 times in a loop Co-authored-by: Andrea Fioraldi --- libafl/src/mutators/mutations.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/libafl/src/mutators/mutations.rs b/libafl/src/mutators/mutations.rs index c2dff328ce..4e2443aa1d 100644 --- a/libafl/src/mutators/mutations.rs +++ b/libafl/src/mutators/mutations.rs @@ -1282,17 +1282,12 @@ where let mut other_testcase = state.corpus().get(idx)?.borrow_mut(); let other = other_testcase.load_input(state.corpus())?; - let mut counter: u32 = 0; - loop { - let (f, l) = locate_diffs(input.bytes(), other.bytes()); + let (f, l) = locate_diffs(input.bytes(), other.bytes()); - if f != l && f >= 0 && l >= 2 { - break (f as u64, l as u64); - } - if counter == 3 { - return Ok(MutationResult::Skipped); - } - counter += 1; + if f != l && f >= 0 && l >= 2 { + (f as u64, l as u64) + } else { + return Ok(MutationResult::Skipped); } };