mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-08 06:53:45 +00:00
ICU-11709 do not clobber existing UErrorCode failure code, do not orphan() names until you know that the Enumeration was allocated and thus did adopt
X-SVN-Rev: 37956
This commit is contained in:
parent
6d31a2bfa2
commit
5faab922bd
1 changed files with 11 additions and 4 deletions
|
@ -244,7 +244,7 @@ UBool NumberingSystem::isAlgorithmic() const {
|
|||
}
|
||||
|
||||
StringEnumeration* NumberingSystem::getAvailableNames(UErrorCode &status) {
|
||||
|
||||
// TODO(ticket #11908): Init-once static cache, with u_cleanup() callback.
|
||||
static StringEnumeration* availableNames = NULL;
|
||||
|
||||
if (U_FAILURE(status)) {
|
||||
|
@ -252,9 +252,9 @@ StringEnumeration* NumberingSystem::getAvailableNames(UErrorCode &status) {
|
|||
}
|
||||
|
||||
if ( availableNames == NULL ) {
|
||||
// TODO: Simple array of UnicodeString objects, based on length of table resource?
|
||||
LocalPointer<UVector> numsysNames(new UVector(uprv_deleteUObject, NULL, status), status);
|
||||
if (U_FAILURE(status)) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -275,8 +275,15 @@ StringEnumeration* NumberingSystem::getAvailableNames(UErrorCode &status) {
|
|||
}
|
||||
|
||||
ures_close(numberingSystemsInfo);
|
||||
availableNames = new NumsysNameEnumeration(numsysNames.orphan(),status);
|
||||
|
||||
if (U_FAILURE(status)) {
|
||||
return NULL;
|
||||
}
|
||||
availableNames = new NumsysNameEnumeration(numsysNames.getAlias(), status);
|
||||
if (availableNames == NULL) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
numsysNames.orphan(); // The names got adopted.
|
||||
}
|
||||
|
||||
return availableNames;
|
||||
|
|
Loading…
Add table
Reference in a new issue