From c03653f7bef8dcd3fcfbdee81ab04f3e21e4f659 Mon Sep 17 00:00:00 2001 From: Romain Malmain Date: Wed, 9 Oct 2024 17:16:53 +0200 Subject: [PATCH] Remove useless allocation in colorization stage (#2598) * do not allocate here * clippy --- libafl/src/stages/colorization.rs | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/libafl/src/stages/colorization.rs b/libafl/src/stages/colorization.rs index 69a45b29f3..11ee585780 100644 --- a/libafl/src/stages/colorization.rs +++ b/libafl/src/stages/colorization.rs @@ -189,20 +189,11 @@ where // This is the buffer we'll randomly mutate during type_replace let mut changed = input.clone(); - // input will be consumed so clone it - let consumed_input = input.clone(); - // First, run orig_input once and get the original hash // Idea: No need to do this every time - let orig_hash = Self::get_raw_map_hash_run( - fuzzer, - executor, - state, - manager, - consumed_input, - observer_handle, - )?; + let orig_hash = + Self::get_raw_map_hash_run(fuzzer, executor, state, manager, &input, observer_handle)?; let changed_bytes = changed.bytes_mut(); let input_len = changed_bytes.len(); @@ -240,13 +231,12 @@ where ); } - let consumed_input = input.clone(); let changed_hash = Self::get_raw_map_hash_run( fuzzer, executor, state, manager, - consumed_input, + &input, observer_handle, )?; @@ -333,12 +323,12 @@ where executor: &mut E, state: &mut ::State, manager: &mut EM, - input: E::Input, + input: &E::Input, observer_handle: &Handle, ) -> Result { - executor.observers_mut().pre_exec_all(state, &input)?; + executor.observers_mut().pre_exec_all(state, input)?; - let exit_kind = executor.run_target(fuzzer, state, manager, &input)?; + let exit_kind = executor.run_target(fuzzer, state, manager, input)?; let observers = executor.observers(); let observer = observers[observer_handle].as_ref(); @@ -347,7 +337,7 @@ where executor .observers_mut() - .post_exec_all(state, &input, &exit_kind)?; + .post_exec_all(state, input, &exit_kind)?; // let observers = executor.observers(); // fuzzer.process_execution(state, manager, input, observers, &exit_kind, true)?;