From 037e5ac5080d0f38b7d62d34ef87485d3595d8b3 Mon Sep 17 00:00:00 2001 From: Andy Heninger Date: Mon, 12 Jul 2010 17:24:09 +0000 Subject: [PATCH] ICU-7816 time zone infinite loop breaking X-SVN-Rev: 28298 --- icu4c/source/i18n/basictz.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/icu4c/source/i18n/basictz.cpp b/icu4c/source/i18n/basictz.cpp index f602326fb8e..baadc37363a 100644 --- a/icu4c/source/i18n/basictz.cpp +++ b/icu4c/source/i18n/basictz.cpp @@ -360,7 +360,14 @@ BasicTimeZone::getTimeZoneRulesAfter(UDate start, InitialTimeZoneRule*& initial, if (!avail) { break; } - time = tzt.getTime(); + UDate updatedTime = tzt.getTime(); + if (updatedTime == time) { + // Time zones that have been manually initialized with inconsistent transtion rules + // can bring us here. Bail out to prevent an infinite loop. + status = U_INVALID_STATE_ERROR; + goto error; + } + time = updatedTime; const TimeZoneRule *toRule = tzt.getTo(); for (i = 0; i < ruleCount; i++) { @@ -511,6 +518,14 @@ error: delete orgRules; } if (done != NULL) { + if (filteredRules != NULL) { + while (!filteredRules->isEmpty()) { + r = (TimeZoneRule*)filteredRules->orphanElementAt(0); + delete r; + } + delete filteredRules; + } + delete res_initial; uprv_free(done); }