From 92db678995423c217abdf3614e1ca92571dc151e Mon Sep 17 00:00:00 2001 From: AshrafIbrahim03 <123664304+AshrafIbrahim03@users.noreply.github.com> Date: Mon, 30 Dec 2024 14:47:04 -0500 Subject: [PATCH] Added expect error message to TimeFeedback where there used to be an unwrap (#2777) * Added expect error message to TimeFeedback where there used to be an unwrap * Changed error message handling * fixed cargo clippy --------- Co-authored-by: Dominik Maier --- libafl/src/feedbacks/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libafl/src/feedbacks/mod.rs b/libafl/src/feedbacks/mod.rs index 5fbf13f64a..49e9f2e2d7 100644 --- a/libafl/src/feedbacks/mod.rs +++ b/libafl/src/feedbacks/mod.rs @@ -932,7 +932,12 @@ where observers: &OT, testcase: &mut Testcase, ) -> Result<(), Error> { - let observer = observers.get(&self.observer_handle).unwrap(); + let Some(observer) = observers.get(&self.observer_handle) else { + return Err(Error::illegal_state( + "Observer referenced by TimeFeedback is not found in observers given to the fuzzer", + )); + }; + *testcase.exec_time_mut() = *observer.last_runtime(); Ok(()) }