mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-06 14:05:32 +00:00
ICU-22277 correct collation error return of uninitialized length value while previous code return error
See #2320
This commit is contained in:
parent
32bc47eefe
commit
47b321f1fa
3 changed files with 25 additions and 1 deletions
|
@ -390,7 +390,7 @@ CollationLoader::loadFromData(UErrorCode &errorCode) {
|
|||
LocalUResourceBundlePointer binary(ures_getByKey(data, "%%CollationBin", nullptr, &errorCode));
|
||||
// Note: U_MISSING_RESOURCE_ERROR --> The old code built from rules if available
|
||||
// but that created undesirable dependencies.
|
||||
int32_t length;
|
||||
int32_t length = 0;
|
||||
const uint8_t *inBytes = ures_getBinary(binary.getAlias(), &length, &errorCode);
|
||||
CollationDataReader::read(rootEntry->tailoring, inBytes, length, *t, errorCode);
|
||||
// Note: U_COLLATOR_VERSION_MISMATCH --> The old code built from rules if available
|
||||
|
|
|
@ -1249,6 +1249,26 @@ void CollationRegressionTest::TestBeforeWithTooStrongAfter() {
|
|||
}
|
||||
}
|
||||
|
||||
void CollationRegressionTest::TestICU22277() {
|
||||
IcuTestErrorCode errorCode(*this, "TestICU22277");
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
Collator* c = Collator::createInstance("JA-u-Co-priVatE-KANa", status);
|
||||
if(c != nullptr || U_SUCCESS(status)) {
|
||||
errcheckln(status, "Collator should have failed with MemorySanitizer: use-of-uninitialized-value error - %s",
|
||||
u_errorName(status));
|
||||
delete c;
|
||||
return;
|
||||
}
|
||||
c = Collator::createInstance("hE-U-cO-pRIVate-UNihan", status);
|
||||
if(c != nullptr || U_SUCCESS(status)) {
|
||||
errcheckln(status, "Collator should have failed with MemorySanitizer: use-of-uninitialized-value error - %s",
|
||||
u_errorName(status));
|
||||
delete c;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void CollationRegressionTest::compareArray(Collator &c,
|
||||
const char16_t tests[][CollationRegressionTest::MAX_TOKEN_LEN],
|
||||
int32_t testCount)
|
||||
|
@ -1387,6 +1407,7 @@ void CollationRegressionTest::runIndexedTest(int32_t index, UBool exec, const ch
|
|||
TESTCASE_AUTO(TestCaseFirstCompression);
|
||||
TESTCASE_AUTO(TestTrailingComment);
|
||||
TESTCASE_AUTO(TestBeforeWithTooStrongAfter);
|
||||
TESTCASE_AUTO(TestICU22277);
|
||||
TESTCASE_AUTO_END;
|
||||
}
|
||||
|
||||
|
|
|
@ -237,6 +237,9 @@ public:
|
|||
void TestTrailingComment();
|
||||
void TestBeforeWithTooStrongAfter();
|
||||
|
||||
// Test use-of-uninitialized-value
|
||||
void TestICU22277();
|
||||
|
||||
private:
|
||||
//------------------------------------------------------------------------
|
||||
// Internal utilities
|
||||
|
|
Loading…
Add table
Reference in a new issue