summaryrefslogtreecommitdiffstats
path: root/i18npool
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2013-03-09 18:47:29 +0100
committerEike Rathke <erack@redhat.com>2013-03-09 18:50:33 +0100
commitccc349d3abb70ef38cd2b7706da51b060a385908 (patch)
tree8c057e5d499bece8ad6c5408f05a0835638947a8 /i18npool
parentregex: handle zero-length matches, fdo#60259 related (diff)
downloadcore-ccc349d3abb70ef38cd2b7706da51b060a385908.tar.gz
core-ccc349d3abb70ef38cd2b7706da51b060a385908.zip
regex: don't loop 10000 identical matches to find a single $ anchor
Change-Id: Ic130ecc4b0b6d58ba7ef063040bd9a11a90db425
Diffstat (limited to 'i18npool')
-rw-r--r--i18npool/source/search/textsearch.cxx5
1 files changed, 5 insertions, 0 deletions
diff --git a/i18npool/source/search/textsearch.cxx b/i18npool/source/search/textsearch.cxx
index 14ecdcc1059d..997b01dd6afa 100644
--- a/i18npool/source/search/textsearch.cxx
+++ b/i18npool/source/search/textsearch.cxx
@@ -752,6 +752,11 @@ SearchResult TextSearch::RESrchFrwrd( const OUString& searchStr,
int nEndOfs = pRegexMatcher->end( nIcuErr);
if( nStartOfs < nEndOfs)
break;
+ // If the zero-length match is behind the string, do not match it again
+ // and again until startPos reaches there. A match behind the string is
+ // a "$" anchor.
+ if (nStartOfs == endPos)
+ break;
// try at next position if there was a zero-length match
if( ++startPos >= endPos)
return aRet;