From 52d192e2b5345c52ceba6dea4366c4d069850970 Mon Sep 17 00:00:00 2001 From: Peter Edberg Date: Mon, 8 Apr 2019 11:48:06 -0700 Subject: [PATCH] ICU-20537 jaEra: fix leak in SimpleDateFormat::applyPattern --- icu4c/source/i18n/smpdtfmt.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/icu4c/source/i18n/smpdtfmt.cpp b/icu4c/source/i18n/smpdtfmt.cpp index 4a2ccb7f8e7..e67c4538287 100644 --- a/icu4c/source/i18n/smpdtfmt.cpp +++ b/icu4c/source/i18n/smpdtfmt.cpp @@ -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 } }