i18npool/source/breakiterator/xdictionary.cxx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
New commits: commit 1ad97f9b803d07702d52f44b2d6ce7235ff9400a Author: David Tardon <dtar...@redhat.com> Date: Wed Oct 15 17:05:33 2014 +0200 avoid out-of-bounds access when iterating code points Change-Id: I583e49180b37705ea124c0d88c2e2a8cb1470dfe diff --git a/i18npool/source/breakiterator/xdictionary.cxx b/i18npool/source/breakiterator/xdictionary.cxx index 567a2db..6f7c196 100644 --- a/i18npool/source/breakiterator/xdictionary.cxx +++ b/i18npool/source/breakiterator/xdictionary.cxx @@ -403,7 +403,9 @@ WordBreakCache& xdictionary::getCache(const sal_Unicode *text, Boundary& wordBou Boundary xdictionary::previousWord(const OUString& rText, sal_Int32 anyPos, sal_Int16 wordType) { // looking for the first non-whitespace character from anyPos - sal_uInt32 ch = rText.iterateCodePoints(&anyPos, -1); + sal_uInt32 ch = 0; + if (anyPos > 0) + rText.iterateCodePoints(&anyPos, -1); while (anyPos > 0 && u_isWhitespace(ch)) ch = rText.iterateCodePoints(&anyPos, -1); commit 4a97029ce71262395620b71633b309f3e6bb6f54 Author: David Tardon <dtar...@redhat.com> Date: Wed Oct 15 17:02:59 2014 +0200 avoid out-of-bounds access when iterating code points Change-Id: I88290e5ccfd6ab250fe1526e452609e6de020dcd diff --git a/i18npool/source/breakiterator/xdictionary.cxx b/i18npool/source/breakiterator/xdictionary.cxx index b930f46..567a2db 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); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits