Don't panic even if bitmap is zero in calibrate.rs (#2419)

This commit is contained in:
Dongjia "toka" Zhang 2024-07-17 18:26:17 +02:00 committed by GitHub
parent c96ea616fe
commit 536f00a056
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 3 deletions

View File

@ -35,10 +35,10 @@ use serde::{Deserialize, Serialize};
#[cfg(feature = "std")]
use typed_builder::TypedBuilder;
#[cfg(feature = "std")]
use crate::events::{AdaptiveSerializer, CustomBufEventResult, HasCustomBufHandlers};
#[cfg(all(unix, feature = "std", not(miri)))]
use crate::events::EVENTMGR_SIGHANDLER_STATE;
#[cfg(feature = "std")]
use crate::events::{AdaptiveSerializer, CustomBufEventResult, HasCustomBufHandlers};
use crate::{
events::{
Event, EventConfig, EventFirer, EventManager, EventManagerHooksTuple, EventManagerId,

View File

@ -2,6 +2,7 @@
use alloc::{
borrow::{Cow, ToOwned},
string::ToString,
vec::Vec,
};
use core::{fmt::Debug, marker::PhantomData, time::Duration};
@ -260,7 +261,14 @@ where
let map = observers[&self.map_observer_handle].as_ref();
let mut bitmap_size = map.count_bytes();
assert!(bitmap_size != 0);
if bitmap_size < 1 {
return Err(Error::invalid_corpus(
"This testcase doesnot trigger trigger any edges. Check your instrumentation!"
.to_string(),
));
}
bitmap_size = bitmap_size.max(1); // just don't make it 0 because we take log2 of it later.
let psmeta = state
.metadata_map_mut()