diff --git a/icu4c/source/common/ustrenum.cpp b/icu4c/source/common/ustrenum.cpp index 169aa8d0d1..2bf12bfe03 100644 --- a/icu4c/source/common/ustrenum.cpp +++ b/icu4c/source/common/ustrenum.cpp @@ -21,7 +21,11 @@ StringEnumeration::StringEnumeration() : chars(charsBuffer), charsCapacity(sizeof(charsBuffer)) { } -StringEnumeration::~StringEnumeration() {} +StringEnumeration::~StringEnumeration() { + if (chars != NULL && chars != charsBuffer) { + uprv_free(chars); + } +} // StringEnumeration base class clone() default implementation, does not clone StringEnumeration * diff --git a/icu4c/source/i18n/ucurr.cpp b/icu4c/source/i18n/ucurr.cpp index 861091d76e..2ea5412e62 100644 --- a/icu4c/source/i18n/ucurr.cpp +++ b/icu4c/source/i18n/ucurr.cpp @@ -317,7 +317,7 @@ ucurr_forLocale(const char* locale, // Look up the CurrencyMap element in the root bundle. UResourceBundle *rb = ures_open(NULL, "", &localStatus); - UResourceBundle *cm = ures_getByKey(rb, CURRENCY_MAP, NULL, &localStatus); + UResourceBundle *cm = ures_getByKey(rb, CURRENCY_MAP, rb, &localStatus); s = ures_getStringByKey(cm, id, &resLen, &localStatus); if ((s == NULL || U_FAILURE(localStatus)) && variantType != VARIANT_IS_EMPTY @@ -330,6 +330,7 @@ ucurr_forLocale(const char* locale, else { uloc_getParent(locale, id, sizeof(id), ec); *ec = U_USING_FALLBACK_WARNING; + ures_close(cm); return ucurr_forLocale(id, buff, buffCapacity, ec); } } @@ -343,7 +344,6 @@ ucurr_forLocale(const char* locale, } } ures_close(cm); - ures_close(rb); } return u_terminateUChars(buff, buffCapacity, resLen, ec); } else {