summaryrefslogtreecommitdiff
path: root/i18npool/source/breakiterator
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2014-10-15 17:02:59 +0200
committerDavid Tardon <dtardon@redhat.com>2014-10-15 17:07:36 +0200
commit4a97029ce71262395620b71633b309f3e6bb6f54 (patch)
tree11c0a2ef2649e37583282fc09c986f6f30ee2315 /i18npool/source/breakiterator
parentb1023801e4fecd532a1252a206563e6f6e71615c (diff)
avoid out-of-bounds access when iterating code points
Change-Id: I88290e5ccfd6ab250fe1526e452609e6de020dcd
Diffstat (limited to 'i18npool/source/breakiterator')
-rw-r--r--i18npool/source/breakiterator/xdictionary.cxx8
1 files changed, 5 insertions, 3 deletions
diff --git a/i18npool/source/breakiterator/xdictionary.cxx b/i18npool/source/breakiterator/xdictionary.cxx
index b930f46d9840..567a2db1aced 100644
--- a/i18npool/source/breakiterator/xdictionary.cxx
+++ b/i18npool/source/breakiterator/xdictionary.cxx
@@ -414,11 +414,13 @@ Boundary xdictionary::nextWord(const OUString& rText, sal_Int32 anyPos, sal_Int1
{
boundary = getWordBoundary(rText, anyPos, wordType, true);
anyPos = boundary.endPos;
- if (anyPos < rText.getLength()) {
+ const sal_Int32 nLen = rText.getLength();
+ if (anyPos < nLen) {
// looknig for the first non-whitespace character from anyPos
sal_uInt32 ch = rText.iterateCodePoints(&anyPos, 1);
- while (u_isWhitespace(ch)) ch=rText.iterateCodePoints(&anyPos, 1);
- rText.iterateCodePoints(&anyPos, -1);
+ while (u_isWhitespace(ch) && (anyPos < nLen)) ch=rText.iterateCodePoints(&anyPos, 1);
+ if (anyPos > 0)
+ rText.iterateCodePoints(&anyPos, -1);
}
return getWordBoundary(rText, anyPos, wordType, true);