ICU-21035 Replace backward compatibility ulocimp_getCountry() overload.
By always calling the dynamic memory allocation implementation directly instead, the fixed memory buffer boundary gets pushed one step further towards the edges.
This commit is contained in:
parent
db3278a71e
commit
e8f3d5c657
@ -509,8 +509,7 @@ parseTagString(
|
||||
}
|
||||
}
|
||||
|
||||
subtagLength = ulocimp_getCountry(position, region, *regionLength, &position);
|
||||
u_terminateChars(region, *regionLength, subtagLength, err);
|
||||
subtagLength = ulocimp_getCountry(position, &position, *err).extract(region, *regionLength, *err);
|
||||
|
||||
if(U_FAILURE(*err)) {
|
||||
goto error;
|
||||
|
@ -1215,7 +1215,7 @@ ulocimp_getScript(const char *localeID,
|
||||
return result;
|
||||
}
|
||||
|
||||
static CharString
|
||||
CharString U_EXPORT2
|
||||
ulocimp_getCountry(const char *localeID,
|
||||
const char **pEnd,
|
||||
UErrorCode &status) {
|
||||
@ -1250,14 +1250,6 @@ ulocimp_getCountry(const char *localeID,
|
||||
return result;
|
||||
}
|
||||
|
||||
U_CFUNC int32_t
|
||||
ulocimp_getCountry(const char *localeID,
|
||||
char *country, int32_t countryCapacity,
|
||||
const char **pEnd) {
|
||||
ErrorCode status;
|
||||
return ulocimp_getCountry(localeID, pEnd, status).extract(country, countryCapacity, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param needSeparator if true, then add leading '_' if any variants
|
||||
* are added to 'variant'
|
||||
@ -1458,7 +1450,10 @@ uloc_openKeywords(const char* localeID,
|
||||
}
|
||||
/* Skip the Country */
|
||||
if (_isIDSeparator(*tmpLocaleID)) {
|
||||
ulocimp_getCountry(tmpLocaleID+1, NULL, 0, &tmpLocaleID);
|
||||
ulocimp_getCountry(tmpLocaleID+1, &tmpLocaleID, *status);
|
||||
if (U_FAILURE(*status)) {
|
||||
return 0;
|
||||
}
|
||||
if(_isIDSeparator(*tmpLocaleID)) {
|
||||
_getVariant(tmpLocaleID+1, *tmpLocaleID, NULL, 0);
|
||||
}
|
||||
@ -1750,8 +1745,6 @@ uloc_getCountry(const char* localeID,
|
||||
int32_t countryCapacity,
|
||||
UErrorCode* err)
|
||||
{
|
||||
int32_t i=0;
|
||||
|
||||
if(err==NULL || U_FAILURE(*err)) {
|
||||
return 0;
|
||||
}
|
||||
@ -1778,10 +1771,10 @@ uloc_getCountry(const char* localeID,
|
||||
localeID = scriptID;
|
||||
}
|
||||
if(_isIDSeparator(*localeID)) {
|
||||
i=ulocimp_getCountry(localeID+1, country, countryCapacity, NULL);
|
||||
return ulocimp_getCountry(localeID+1, NULL, *err).extract(country, countryCapacity, *err);
|
||||
}
|
||||
}
|
||||
return u_terminateChars(country, countryCapacity, i, err);
|
||||
return u_terminateChars(country, countryCapacity, 0, err);
|
||||
}
|
||||
|
||||
U_CAPI int32_t U_EXPORT2
|
||||
@ -1827,7 +1820,10 @@ uloc_getVariant(const char* localeID,
|
||||
/* Skip the Country */
|
||||
if (_isIDSeparator(*tmpLocaleID)) {
|
||||
const char *cntryID;
|
||||
ulocimp_getCountry(tmpLocaleID+1, NULL, 0, &cntryID);
|
||||
ulocimp_getCountry(tmpLocaleID+1, &cntryID, *err);
|
||||
if (U_FAILURE(*err)) {
|
||||
return 0;
|
||||
}
|
||||
if (cntryID != tmpLocaleID+1) {
|
||||
/* Found optional country */
|
||||
tmpLocaleID = cntryID;
|
||||
|
@ -59,10 +59,10 @@ ulocimp_getScript(const char *localeID,
|
||||
const char **pEnd,
|
||||
UErrorCode &status);
|
||||
|
||||
U_CFUNC int32_t
|
||||
icu::CharString U_EXPORT2
|
||||
ulocimp_getCountry(const char *localeID,
|
||||
char *country, int32_t countryCapacity,
|
||||
const char **pEnd);
|
||||
const char **pEnd,
|
||||
UErrorCode &status);
|
||||
|
||||
U_STABLE void U_EXPORT2
|
||||
ulocimp_getName(const char* localeID,
|
||||
|
Loading…
Reference in New Issue
Block a user