ICU-13127 Fix crashing bug in UnicodeString::toTitle()
X-SVN-Rev: 40036
This commit is contained in:
parent
8e4379f9e7
commit
5dca4ba1e1
@ -50,7 +50,11 @@ UnicodeString::toTitle(BreakIterator *titleIter, const Locale &locale, uint32_t
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bi->setText(*this);
|
// Because the "this" string is both the source and the destination,
|
||||||
|
// make a copy of the original source for use by the break iterator.
|
||||||
|
// See tickets #13127 and #13128
|
||||||
|
UnicodeString copyOfInput(*this);
|
||||||
|
bi->setText(copyOfInput);
|
||||||
caseMap(ustrcase_getCaseLocale(locale.getBaseName()), options, bi, ustrcase_internalToTitle);
|
caseMap(ustrcase_getCaseLocale(locale.getBaseName()), options, bi, ustrcase_internalToTitle);
|
||||||
if(titleIter==NULL) {
|
if(titleIter==NULL) {
|
||||||
delete bi;
|
delete bi;
|
||||||
|
@ -61,6 +61,7 @@ public:
|
|||||||
void TestCaseMapWithEdits();
|
void TestCaseMapWithEdits();
|
||||||
void TestCaseMapUTF8WithEdits();
|
void TestCaseMapUTF8WithEdits();
|
||||||
void TestLongUnicodeString();
|
void TestLongUnicodeString();
|
||||||
|
void TestBug13127();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void assertGreekUpper(const char16_t *s, const char16_t *expected);
|
void assertGreekUpper(const char16_t *s, const char16_t *expected);
|
||||||
@ -89,6 +90,7 @@ StringCaseTest::runIndexedTest(int32_t index, UBool exec, const char *&name, cha
|
|||||||
TESTCASE_AUTO(TestCaseConversion);
|
TESTCASE_AUTO(TestCaseConversion);
|
||||||
#if !UCONFIG_NO_BREAK_ITERATION && !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION
|
#if !UCONFIG_NO_BREAK_ITERATION && !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION
|
||||||
TESTCASE_AUTO(TestCasing);
|
TESTCASE_AUTO(TestCasing);
|
||||||
|
TESTCASE_AUTO(TestBug13127);
|
||||||
#endif
|
#endif
|
||||||
TESTCASE_AUTO(TestFullCaseFoldingIterator);
|
TESTCASE_AUTO(TestFullCaseFoldingIterator);
|
||||||
TESTCASE_AUTO(TestGreekUpper);
|
TESTCASE_AUTO(TestGreekUpper);
|
||||||
@ -1138,3 +1140,10 @@ void StringCaseTest::TestLongUnicodeString() {
|
|||||||
s.toUpper(Locale::getRoot());
|
s.toUpper(Locale::getRoot());
|
||||||
assertEquals("string length 306", expected, s);
|
assertEquals("string length 306", expected, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StringCaseTest::TestBug13127() {
|
||||||
|
// Test case crashed when the bug was present.
|
||||||
|
const char16_t *s16 = u"日本語";
|
||||||
|
UnicodeString s(TRUE, s16, -1);
|
||||||
|
s.toTitle(0, Locale::getEnglish());
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user