Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions crates/libafl/src/mutators/mutations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1513,13 +1513,18 @@ where
return Ok(MutationResult::Skipped);
}

let other_size = {
// Load and map the input once, cloning the result for later use after dropping the borrow
let mapped_other_input = {
let mut other_testcase = state.corpus().get_from_all(id)?.borrow_mut();
let other_input = other_testcase.load_input(state.corpus())?;
let input_mapped = (self.input_mapper)(other_input).map_to_option_bytes();
input_mapped.map_or(0, <Vec<u8>>::len)
match (self.input_mapper)(other_input).map_to_option_bytes() {
Some(m) => m.clone(),
None => return Ok(MutationResult::Skipped),
}
};

let other_size = mapped_other_input.len();

if other_size < 2 {
return Ok(MutationResult::Skipped);
}
Expand All @@ -1536,21 +1541,12 @@ where
.rand_mut()
.below(unsafe { NonZero::new_unchecked(size) });

let other_testcase = state.corpus().get_from_all(id)?.borrow_mut();
// No need to load the input again, it'll still be cached.
let other_input = &mut other_testcase.input().as_ref().unwrap();
let wrapped_mapped_other_input = (self.input_mapper)(other_input).map_to_option_bytes();
if wrapped_mapped_other_input.is_none() {
return Ok(MutationResult::Skipped);
}
let mapped_other_input = wrapped_mapped_other_input.unwrap();

Ok(CrossoverInsertMutator::crossover_insert(
input,
size,
target,
range,
mapped_other_input,
&mapped_other_input,
))
}
#[inline]
Expand Down
Loading