From fb0a23e767b8bd66a6972e72203f9a298ada84be Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Sat, 10 Apr 2021 19:57:30 +0200 Subject: [PATCH] cleaned up potential panic --- libafl/src/corpus/minimizer.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libafl/src/corpus/minimizer.rs b/libafl/src/corpus/minimizer.rs index 6b90d9dad3..e4f12f95a1 100644 --- a/libafl/src/corpus/minimizer.rs +++ b/libafl/src/corpus/minimizer.rs @@ -199,15 +199,15 @@ where /// Cull the `Corpus` using the `MinimizerCorpusScheduler` #[allow(clippy::unused_self)] pub fn cull(&self, state: &mut S) -> Result<(), Error> { - if state.metadata().get::().is_none() { - return Ok(()); - } - let mut acc = HashSet::new(); - let top_rated = state.metadata().get::().unwrap(); + let top_rated = match state.metadata().get::() { + None => return Ok(()), + Some(val) => val, + }; - for key in top_rated.map.keys() { + let mut acc = HashSet::new(); + + for (key, idx) in &top_rated.map { if !acc.contains(key) { - let idx = top_rated.map.get(key).unwrap(); let mut entry = state.corpus().get(*idx)?.borrow_mut(); let meta = entry.metadata().get::().ok_or_else(|| { Error::KeyNotFound(format!(