Make sure input was loaded to avoid panic on unwrap in MutatedTransform (#1077)
* make sure input was loaded to avoid panic on unwrap fixes issue #1059 * avoid unnecessary clone, avoid unnecessary branching --------- Co-authored-by: Michael Rodler <m@mrodler.eu> Co-authored-by: Addison Crump <addison.crump@cispa.de>
This commit is contained in:
parent
f454d17482
commit
46b75747ef
@ -108,7 +108,7 @@ where
|
|||||||
type Post = Self;
|
type Post = Self;
|
||||||
|
|
||||||
fn try_transform_from(
|
fn try_transform_from(
|
||||||
base: &Testcase<BytesInput>,
|
base: &mut Testcase<BytesInput>,
|
||||||
_state: &S,
|
_state: &S,
|
||||||
corpus_idx: CorpusId,
|
corpus_idx: CorpusId,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
|
@ -51,7 +51,7 @@ where
|
|||||||
|
|
||||||
/// Transform the provided testcase into this type
|
/// Transform the provided testcase into this type
|
||||||
fn try_transform_from(
|
fn try_transform_from(
|
||||||
base: &Testcase<I>,
|
base: &mut Testcase<I>,
|
||||||
state: &S,
|
state: &S,
|
||||||
corpus_idx: CorpusId,
|
corpus_idx: CorpusId,
|
||||||
) -> Result<Self, Error>;
|
) -> Result<Self, Error>;
|
||||||
@ -69,11 +69,11 @@ where
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn try_transform_from(
|
fn try_transform_from(
|
||||||
base: &Testcase<I>,
|
base: &mut Testcase<I>,
|
||||||
_state: &S,
|
_state: &S,
|
||||||
_corpus_idx: CorpusId,
|
_corpus_idx: CorpusId,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
Ok(base.input().as_ref().unwrap().clone())
|
Ok(base.load_input()?.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -116,8 +116,8 @@ where
|
|||||||
let num = self.iterations(state, corpus_idx)?;
|
let num = self.iterations(state, corpus_idx)?;
|
||||||
|
|
||||||
start_timer!(state);
|
start_timer!(state);
|
||||||
let testcase = state.corpus().get(corpus_idx)?.borrow();
|
let mut testcase = state.corpus().get(corpus_idx)?.borrow_mut();
|
||||||
let Ok(input) = I::try_transform_from(&testcase, state, corpus_idx) else { return Ok(()); };
|
let Ok(input) = I::try_transform_from(&mut testcase, state, corpus_idx) else { return Ok(()); };
|
||||||
drop(testcase);
|
drop(testcase);
|
||||||
mark_feature_time!(state, PerfFeature::GetInputFromCorpus);
|
mark_feature_time!(state, PerfFeature::GetInputFromCorpus);
|
||||||
|
|
||||||
|
@ -82,8 +82,8 @@ where
|
|||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let num = self.iterations(state, corpus_idx)?;
|
let num = self.iterations(state, corpus_idx)?;
|
||||||
|
|
||||||
let testcase = state.corpus().get(corpus_idx)?.borrow();
|
let mut testcase = state.corpus().get(corpus_idx)?.borrow_mut();
|
||||||
let Ok(input) = I::try_transform_from(&testcase, state, corpus_idx) else { return Ok(()); };
|
let Ok(input) = I::try_transform_from(&mut testcase, state, corpus_idx) else { return Ok(()); };
|
||||||
drop(testcase);
|
drop(testcase);
|
||||||
|
|
||||||
for i in 0..num {
|
for i in 0..num {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user