ICU-20537 jaEra: fix leak in SimpleDateFormat::applyPattern

This commit is contained in:
Peter Edberg 2019-04-08 11:48:06 -07:00 committed by pedberg-icu
parent 2f06d1de55
commit 52d192e2b5

View file

@ -3909,13 +3909,13 @@ SimpleDateFormat::applyPattern(const UnicodeString& pattern)
if (fSharedNumberFormatters != NULL) {
Locale ovrLoc(fLocale.getLanguage(),fLocale.getCountry(),fLocale.getVariant(),"numbers=jpanyear");
UErrorCode status = U_ZERO_ERROR;
const SharedNumberFormat *snf = NULL;
SharedObject::copyPtr(createSharedNumberFormat(ovrLoc, status), snf);
const SharedNumberFormat *snf = createSharedNumberFormat(ovrLoc, status);
if (U_SUCCESS(status)) {
// Now that we have an appropriate number formatter, fill in the
// appropriate slot in the number formatters table.
UDateFormatField patternCharIndex = DateFormatSymbols::getPatternCharIndex(u'y');
SharedObject::copyPtr(snf, fSharedNumberFormatters[patternCharIndex]);
snf->deleteIfZeroRefCount();
fDateOverride.setTo(u"y=jpanyear", -1); // record status
}
}