diff --git a/re2/dfa.cc b/re2/dfa.cc index 91292d449..81adb304e 100644 --- a/re2/dfa.cc +++ b/re2/dfa.cc @@ -1415,9 +1415,11 @@ inline bool DFA::InlinedSearchLoop(SearchParams* params, // byte runs at about 0.2 MB/s, while the NFA (nfa.cc) can do the // same at about 2 MB/s. Unless we're processing an average // of 10 bytes per state computation, fail so that RE2 can - // fall back to the NFA. + // 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(p - resetp) < 10*state_cache_.size()) { + static_cast(p - resetp) < 10*state_cache_.size() && + kind_ != Prog::kManyMatch) { params->failed = true; return false; } diff --git a/re2/testing/set_test.cc b/re2/testing/set_test.cc index ad20ed72b..61d1cf295 100644 --- a/re2/testing/set_test.cc +++ b/re2/testing/set_test.cc @@ -201,18 +201,4 @@ TEST(Set, Prefix) { ASSERT_EQ(v[0], 0); } -TEST(Set, OutOfMemory) { - RE2::Set s(RE2::DefaultOptions, RE2::UNANCHORED); - - std::string a(10000, 'a'); - ASSERT_EQ(s.Add(a, NULL), 0); - ASSERT_EQ(s.Compile(), true); - - std::vector v; - RE2::Set::ErrorInfo ei; - ASSERT_EQ(s.Match(a, &v, &ei), false); - ASSERT_EQ(v.size(), 0); - ASSERT_EQ(ei.kind, RE2::Set::kOutOfMemory); -} - } // namespace re2