mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-21 12:40:02 +00:00
ICU-22831 Fix memLeak in number_longnames.cpp by using LocalPointer
Maybe fix issues in ICU-22800
This commit is contained in:
parent
6c8c6aa430
commit
575bb781cf
1 changed files with 3 additions and 4 deletions
|
@ -1481,9 +1481,8 @@ LongNameHandler* LongNameHandler::forCurrencyLongNames(const Locale &loc, const
|
|||
const PluralRules *rules,
|
||||
const MicroPropsGenerator *parent,
|
||||
UErrorCode &status) {
|
||||
auto* result = new LongNameHandler(rules, parent);
|
||||
if (result == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
LocalPointer<LongNameHandler> result(new LongNameHandler(rules, parent), status);
|
||||
if (U_FAILURE(status)) {
|
||||
return nullptr;
|
||||
}
|
||||
UnicodeString simpleFormats[ARRAY_LENGTH];
|
||||
|
@ -1491,7 +1490,7 @@ LongNameHandler* LongNameHandler::forCurrencyLongNames(const Locale &loc, const
|
|||
if (U_FAILURE(status)) { return nullptr; }
|
||||
result->simpleFormatsToModifiers(simpleFormats, {UFIELD_CATEGORY_NUMBER, UNUM_CURRENCY_FIELD}, status);
|
||||
// TODO(icu-units#28): currency gender?
|
||||
return result;
|
||||
return result.orphan();
|
||||
}
|
||||
|
||||
void LongNameHandler::simpleFormatsToModifiers(const UnicodeString *simpleFormats, Field field,
|
||||
|
|
Loading…
Add table
Reference in a new issue