mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 06:25:30 +00:00
ICU-20370 Fix error checking in uloc_getLCID function.
This commit is contained in:
parent
e7d36adf17
commit
85600f2639
2 changed files with 13 additions and 1 deletions
|
@ -2191,7 +2191,7 @@ uloc_getLCID(const char* localeID)
|
|||
}
|
||||
|
||||
uloc_getLanguage(localeID, langID, sizeof(langID), &status);
|
||||
if (U_FAILURE(status)) {
|
||||
if (U_FAILURE(status) || status == U_STRING_NOT_TERMINATED_WARNING) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ static void TestUnicodeDefines(void);
|
|||
|
||||
static void TestIsRightToLeft(void);
|
||||
static void TestBadLocaleIDs(void);
|
||||
static void TestBug20370(void);
|
||||
|
||||
void PrintDataTable();
|
||||
|
||||
|
@ -266,6 +267,7 @@ void addLocaleTest(TestNode** root)
|
|||
TESTCASE(TestToUnicodeLocaleType);
|
||||
TESTCASE(TestToLegacyType);
|
||||
TESTCASE(TestBadLocaleIDs);
|
||||
TESTCASE(TestBug20370);
|
||||
}
|
||||
|
||||
|
||||
|
@ -6498,3 +6500,13 @@ static void TestBadLocaleIDs() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test case for ICU-20370.
|
||||
// The issue shows as an Addresss Sanitizer failure.
|
||||
static void TestBug20370() {
|
||||
const char *localeID = "x-privatebutreallylongtagfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar";
|
||||
uint32_t lcid = uloc_getLCID(localeID);
|
||||
if (lcid != 0) {
|
||||
log_err("FAIL: Expected LCID value of 0 for invalid localeID input.");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue