Skip to content

Commit

Permalink
automata: remove 'is_quit_state' debug assertions
Browse files Browse the repository at this point in the history
It's not feasible for us to check such things when deserializing a DFA,
so we just have no real choice but to remove the assert and let the
search proceed with incorrect results. I had previously wrote these as
real asserts and then swapped them to debug_asserts, but of course, the
fuzzer still trips over them.

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=60652
  • Loading branch information
BurntSushi committed Oct 9, 2023
1 parent 0689353 commit 912479c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 10 deletions.
Binary file not shown.
10 changes: 0 additions & 10 deletions regex-automata/src/dfa/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ fn find_fwd_imp<A: Automaton + ?Sized>(
// It's important that this is a debug_assert, since this can
// actually be tripped even if DFA::from_bytes succeeds and
// returns a supposedly valid DFA.
debug_assert!(dfa.is_quit_state(sid));
return Err(MatchError::quit(input.haystack()[at], at));
}
}
Expand Down Expand Up @@ -297,7 +296,6 @@ fn find_rev_imp<A: Automaton + ?Sized>(
} else if dfa.is_dead_state(sid) {
return Ok(mat);
} else {
debug_assert!(dfa.is_quit_state(sid));
return Err(MatchError::quit(input.haystack()[at], at));
}
}
Expand Down Expand Up @@ -422,7 +420,6 @@ fn find_overlapping_fwd_imp<A: Automaton + ?Sized>(
} else if dfa.is_dead_state(sid) {
return Ok(());
} else {
debug_assert!(dfa.is_quit_state(sid));
return Err(MatchError::quit(
input.haystack()[state.at],
state.at,
Expand Down Expand Up @@ -526,7 +523,6 @@ pub(crate) fn find_overlapping_rev<A: Automaton + ?Sized>(
} else if dfa.is_dead_state(sid) {
return Ok(());
} else {
debug_assert!(dfa.is_quit_state(sid));
return Err(MatchError::quit(
input.haystack()[state.at],
state.at,
Expand Down Expand Up @@ -600,9 +596,6 @@ fn eoi_fwd<A: Automaton + ?Sized>(
let pattern = dfa.match_pattern(*sid, 0);
*mat = Some(HalfMatch::new(pattern, input.haystack().len()));
}
// N.B. We don't have to check 'is_quit' here because the EOI
// transition can never lead to a quit state.
debug_assert!(!dfa.is_quit_state(*sid));
}
}
Ok(())
Expand Down Expand Up @@ -631,9 +624,6 @@ fn eoi_rev<A: Automaton + ?Sized>(
let pattern = dfa.match_pattern(*sid, 0);
*mat = Some(HalfMatch::new(pattern, 0));
}
// N.B. We don't have to check 'is_quit' here because the EOI
// transition can never lead to a quit state.
debug_assert!(!dfa.is_quit_state(*sid));
}
Ok(())
}
Expand Down

0 comments on commit 912479c

Please sign in to comment.