From: Justin Viiret Date: Thu, 22 Jun 2017 06:51:35 +0000 (+1000) Subject: clear_deeper_reports: clear dfa if dead X-Git-Tag: v4.6.0^2~165 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d4d39b8a98acdedae2e721ae35ce90a19e0e976;p=thirdparty%2Fvectorscan.git clear_deeper_reports: clear dfa if dead If we remove all the reports from the DFA because they're too deep, then clear the DFA without depending on Hopcroft minimisation. --- diff --git a/src/nfa/mcclellancompile_util.cpp b/src/nfa/mcclellancompile_util.cpp index 17e022fe..8bb258d3 100644 --- a/src/nfa/mcclellancompile_util.cpp +++ b/src/nfa/mcclellancompile_util.cpp @@ -187,7 +187,22 @@ bool clear_deeper_reports(raw_dfa &raw, u32 max_offset) { } } - return changed; + if (!changed) { + return false; + } + + // We may have cleared all reports from the DFA, in which case it should + // become empty. + if (all_of_in(raw.states, [](const dstate &ds) { + return ds.reports.empty() && ds.reports_eod.empty(); + })) { + DEBUG_PRINTF("no reports left at all, dfa is dead\n"); + raw.states.clear(); + raw.start_anchored = DEAD_STATE; + raw.start_floating = DEAD_STATE; + } + + return true; } set all_reports(const raw_dfa &rdfa) {