const char* tvalue = uprv_strchr(tkey, '-');
if (tvalue == nullptr) {
status = U_ILLEGAL_ARGUMENT_ERROR;
+ return false;
}
const char* nextTKey = ultag_getTKeyStart(tvalue);
if (nextTKey != nullptr) {
}
const char* tfield = (const char*) tfields.elementAt(i);
const char* tvalue = uprv_strchr(tfield, '-');
+ if (tvalue == nullptr) {
+ status = U_ILLEGAL_ARGUMENT_ERROR;
+ return false;
+ }
// Split the "tkey-tvalue" pair string so that we can canonicalize the tvalue.
- U_ASSERT(tvalue != nullptr);
*((char*)tvalue++) = '\0'; // NULL terminate tkey
output.append(tfield, status).append('-', status);
const char* bcpTValue = ulocimp_toBcpType(tfield, tvalue, nullptr, nullptr);
TESTCASE_AUTO(TestSetUnicodeKeywordValueNullInLongLocale);
TESTCASE_AUTO(TestCanonicalize);
TESTCASE_AUTO(TestLeak21419);
+ TESTCASE_AUTO(TestNullDereferenceWrite21597);
TESTCASE_AUTO(TestLongLocaleSetKeywordAssign);
TESTCASE_AUTO(TestLongLocaleSetKeywordMoveAssign);
TESTCASE_AUTO_END;
// alias of tvalue should be replaced
{ "en-t-m0-NaMeS", "en-t-m0-prprname" },
{ "en-t-s0-ascii-d0-NaMe", "en-t-d0-charname-s0-ascii" },
-
};
int32_t i;
for (i=0; i < UPRV_LENGTHOF(testCases); i++) {
l.canonicalize(status);
status.expectErrorAndReset(U_ILLEGAL_ARGUMENT_ERROR);
}
+
+void LocaleTest::TestNullDereferenceWrite21597() {
+ IcuTestErrorCode status(*this, "TestNullDereferenceWrite21597");
+ Locale l = Locale("zu-t-q5-X1-vKf-KK-Ks-cO--Kc");
+ l.canonicalize(status);
+ status.expectErrorAndReset(U_ILLEGAL_ARGUMENT_ERROR);
+}
void TestSetUnicodeKeywordValueInLongLocale();
void TestSetUnicodeKeywordValueNullInLongLocale();
void TestLeak21419();
+ void TestNullDereferenceWrite21597();
void TestLongLocaleSetKeywordAssign();
void TestLongLocaleSetKeywordMoveAssign();