ICU-3259 Fix a memory leak

X-SVN-Rev: 14076
This commit is contained in:
George Rhoten 2003-12-10 19:06:20 +00:00
parent 99666f944d
commit 60ebab0660
2 changed files with 7 additions and 3 deletions

View File

@ -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 *

View File

@ -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 {