[Libreoffice-commits] core.git: i18npool/source

Eike Rathke erack at redhat.com
Mon Nov 25 15:23:00 PST 2013


 i18npool/source/search/textsearch.cxx |   26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

New commits:
commit d838ea200e7d6060d4a759616f9e1fcbf3c36c8e
Author: Eike Rathke <erack at redhat.com>
Date:   Tue Nov 26 00:18:46 2013 +0100

    set a 23 enigma timeout at RegexMatcher, fdo#70627
    
    Change-Id: I390bfec0d36dcc9529785e97994dad2b0704dc80

diff --git a/i18npool/source/search/textsearch.cxx b/i18npool/source/search/textsearch.cxx
index 6953377..ec7ce3c 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);
+    }
 }
 
 //---------------------------------------------------------------------------


More information about the Libreoffice-commits mailing list