diff options
author | Eike Rathke <erack@redhat.com> | 2013-11-26 00:18:46 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2013-11-26 00:22:31 +0100 |
commit | d838ea200e7d6060d4a759616f9e1fcbf3c36c8e (patch) | |
tree | d51d1187f2fc2b71a57a9be5559ae73a6b4db600 /i18npool | |
parent | 0dd15b4428743cae560c2a433dea10dc471fc587 (diff) |
set a 23 enigma timeout at RegexMatcher, fdo#70627
Change-Id: I390bfec0d36dcc9529785e97994dad2b0704dc80
Diffstat (limited to 'i18npool')
-rw-r--r-- | i18npool/source/search/textsearch.cxx | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/i18npool/source/search/textsearch.cxx b/i18npool/source/search/textsearch.cxx index 695337788ac8..ec7ce3cdc215 100644 --- a/i18npool/source/search/textsearch.cxx +++ b/i18npool/source/search/textsearch.cxx @@ -764,8 +764,30 @@ void TextSearch::RESrchPrepare( const ::com::sun::star::util::SearchOptions& rOp aChevronMatcherE.reset(); #endif pRegexMatcher = new RegexMatcher( aIcuSearchPatStr, nIcuSearchFlags, nIcuErr); - if( nIcuErr) - { delete pRegexMatcher; pRegexMatcher = NULL;} + if (nIcuErr) + { + delete pRegexMatcher; + pRegexMatcher = NULL; + } + else + { + // Pathological patterns may result in exponential run time making the + // application appear to be frozen. Limit that. Documentation for this + // call says + // https://ssl.icu-project.org/apiref/icu4c/classicu_1_1RegexMatcher.html#a6ebcfcab4fe6a38678c0291643a03a00 + // "The units of the limit are steps of the match engine. + // Correspondence with actual processor time will depend on the speed + // of the processor and the details of the specific pattern, but will + // typically be on the order of milliseconds." + // Just what is a good value? 42 is always an answer ... the 23 enigma + // as well.. which on the dev's machine is roughly 50 seconds with the + // pattern of fdo#70627. + /* TODO: make this a configuration settable value and possibly take + * complexity of expression into account and maybe even length of text + * to be matched; currently (2013-11-25) that is at most one 64k + * paragraph per RESrchFrwrd()/RESrchBkwrd() call. */ + pRegexMatcher->setTimeLimit( 23*1000, nIcuErr); + } } //--------------------------------------------------------------------------- |