summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-07-22 12:59:13 +0100
committerJan Holesovsky <kendy@collabora.com>2016-07-29 20:01:23 +0200
commit3221f30da9311472d28f67a2a1af43cabdde71ea (patch)
tree4c79ee2b07aae5f7ec5ab2d3bb336d2e3efca071
parente2f4b5467b4093d9ce5bf31b16e6d5a288bf95fa (diff)
crashtesting: fix tdf92993-1.docx failure
Change-Id: I76f09a09fd6c3b114ba74737d4a1ba5dad0fd28f (cherry picked from commit 5e46e382694587e88ecdebc7fa57e90fbaca7a76) Reviewed-on: https://gerrit.libreoffice.org/27436 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> (cherry picked from commit e213a7cfe79f594065b6d64114749c5f49f2380c)
-rw-r--r--i18npool/qa/cppunit/test_breakiterator.cxx16
-rw-r--r--i18npool/source/breakiterator/breakiterator_unicode.cxx2
2 files changed, 17 insertions, 1 deletions
diff --git a/i18npool/qa/cppunit/test_breakiterator.cxx b/i18npool/qa/cppunit/test_breakiterator.cxx
index 29fc48909d12..1c8b1f9a7ac5 100644
--- a/i18npool/qa/cppunit/test_breakiterator.cxx
+++ b/i18npool/qa/cppunit/test_breakiterator.cxx
@@ -142,6 +142,22 @@ void TestBreakIterator::testLineBreaking()
CPPUNIT_ASSERT_MESSAGE("Expected a break at the start of the line, not at ]", aResult.breakIndex == 0);
}
}
+
+ //this is an example sequence from tdf92993-1.docx caught by the load crashtesting
+ {
+ const sal_Unicode WEIRD1[] = { 0xd83c, 0xdf56, 0xd83c, 0xdf57, 0xd83c, 0xdf46,
+ 0xd83c, 0xdf64, 0x2668, 0xfe0f, 0xd83c, 0xdfc6};
+
+ OUString aTest(WEIRD1, SAL_N_ELEMENTS(WEIRD1));
+
+ aLocale.Language = "en";
+ aLocale.Country = "US";
+
+ {
+ //This must not assert/crash
+ (void)m_xBreak->getLineBreak(aTest, 0, aLocale, 0, aHyphOptions, aUserOptions);
+ }
+ }
}
//See https://bugs.libreoffice.org/show_bug.cgi?id=49629
diff --git a/i18npool/source/breakiterator/breakiterator_unicode.cxx b/i18npool/source/breakiterator/breakiterator_unicode.cxx
index 9fba6a3f05ec..a55149152daa 100644
--- a/i18npool/source/breakiterator/breakiterator_unicode.cxx
+++ b/i18npool/source/breakiterator/breakiterator_unicode.cxx
@@ -423,7 +423,7 @@ LineBreakResults SAL_CALL BreakIterator_Unicode::getLineBreak(
GlueSpace=false;
if (lbr.breakType == BreakType::WORDBOUNDARY) {
nStartPos = lbr.breakIndex;
- if (Text[nStartPos--] == WJ)
+ if (nStartPos >= 0 && Text[nStartPos--] == WJ)
GlueSpace=true;
while (nStartPos >= 0 &&
(u_isWhitespace(Text.iterateCodePoints(&nStartPos, 0)) || Text[nStartPos] == WJ)) {