Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions re2/dfa.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1436,11 +1436,16 @@ inline bool DFA::InlinedSearchLoop(SearchParams* params) {
// of 10 bytes per state computation, fail so that RE2 can
// fall back to the NFA. However, RE2::Set cannot fall back,
// so we just have to keep on keeping on in that case.
if (dfa_should_bail_when_slow && resetp != NULL &&
static_cast<size_t>(p - resetp) < 10*state_cache_.size() &&
kind_ != Prog::kManyMatch) {
params->failed = true;
return false;
if (dfa_should_bail_when_slow && resetp != NULL) {
ptrdiff_t bytes_since_reset_signed =
run_forward ? p - resetp : resetp - p;
size_t bytes_since_reset =
static_cast<size_t>(bytes_since_reset_signed);
if (bytes_since_reset < 10*state_cache_.size() &&
kind_ != Prog::kManyMatch) {
params->failed = true;
return false;
}
}
resetp = p;

Expand Down