From e56b19662c3e484a10c081c27977e3a9dffd6fb2 Mon Sep 17 00:00:00 2001 From: Jeff Genovy <29107334+jefgen@users.noreply.github.com> Date: Thu, 30 May 2019 22:23:35 -0700 Subject: [PATCH] ICU-20647 Fix TimeZone leak in ucal_open if uloc_setKeywordValue fails. --- icu4c/source/i18n/ucal.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/icu4c/source/i18n/ucal.cpp b/icu4c/source/i18n/ucal.cpp index 282d84cd6b0..e8f6d2e96f8 100644 --- a/icu4c/source/i18n/ucal.cpp +++ b/icu4c/source/i18n/ucal.cpp @@ -140,8 +140,8 @@ ucal_open( const UChar* zoneID, if(U_FAILURE(*status)) return 0; - TimeZone* zone = (zoneID==NULL) ? TimeZone::createDefault() - : _createTimeZone(zoneID, len, status); + LocalPointer zone( (zoneID==NULL) ? TimeZone::createDefault() + : _createTimeZone(zoneID, len, status), *status); if (U_FAILURE(*status)) { return NULL; @@ -157,9 +157,9 @@ ucal_open( const UChar* zoneID, if (U_FAILURE(*status)) { return NULL; } - return (UCalendar*)Calendar::createInstance(zone, Locale(localeBuf), *status); + return (UCalendar*)Calendar::createInstance(zone.orphan(), Locale(localeBuf), *status); } - return (UCalendar*)Calendar::createInstance(zone, Locale(locale), *status); + return (UCalendar*)Calendar::createInstance(zone.orphan(), Locale(locale), *status); } U_CAPI void U_EXPORT2