From 8d8b77b5630d171e136acf3a8c3a06646be66c9b Mon Sep 17 00:00:00 2001 From: Michael Ow Date: Fri, 6 Jun 2008 18:44:54 +0000 Subject: [PATCH] ICU-5955 Add deleter for TimeZoneRule. X-SVN-Rev: 24116 --- icu4c/source/i18n/vtzone.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/icu4c/source/i18n/vtzone.cpp b/icu4c/source/i18n/vtzone.cpp index 5d65a3131b7..de37e2e068c 100644 --- a/icu4c/source/i18n/vtzone.cpp +++ b/icu4c/source/i18n/vtzone.cpp @@ -20,6 +20,14 @@ U_NAMESPACE_BEGIN +// This is the deleter that will be use to remove TimeZoneRule +U_CDECL_BEGIN +static void U_CALLCONV +deleteTimeZoneRule(void* obj) { + delete (TimeZoneRule*) obj; +} +U_CDECL_END + // Smybol characters used by RFC2445 VTIMEZONE static const UChar COLON = 0x3A; /* : */ static const UChar SEMICOLON = 0x3B; /* ; */ @@ -1335,6 +1343,9 @@ VTimeZone::parse(UErrorCode& status) { if (U_FAILURE(status)) { goto cleanupParse; } + // Set the deleter to remove TimeZoneRule vectors to avoid memory leaks due to unowned TimeZoneRules. + rules->setDeleter(deleteTimeZoneRule); + dates = new UVector(uhash_deleteUnicodeString, uhash_compareUnicodeString, status); if (U_FAILURE(status)) { goto cleanupParse;