]> granicus.if.org Git - icu/commitdiff
ICU-12577 Fixed a potential null dereference issue in SimpleTimeZone.
authorYoshito Umaoka <y.umaoka@gmail.com>
Wed, 15 Mar 2017 06:07:43 +0000 (06:07 +0000)
committerYoshito Umaoka <y.umaoka@gmail.com>
Wed, 15 Mar 2017 06:07:43 +0000 (06:07 +0000)
X-SVN-Rev: 39815

icu4c/source/i18n/simpletz.cpp

index dc52d9777cbd03d2bdcc1650bde24f97db1fa5cc..e17d14cc7b4f0ac500f943fb7c021aa3175bcdda 100644 (file)
@@ -1189,13 +1189,22 @@ SimpleTimeZone::initTransitionRules(UErrorCode& status) {
         // Create a TimeZoneRule for initial time
         if (firstStdStart < firstDstStart) {
             initialRule = new InitialTimeZoneRule(tzid+UnicodeString(DST_STR), getRawOffset(), dstRule->getDSTSavings());
+            if (initialRule == NULL) {
+                status = U_MEMORY_ALLOCATION_ERROR;
+                deleteTransitionRules();
+                return;
+            }
             firstTransition = new TimeZoneTransition(firstStdStart, *initialRule, *stdRule);
         } else {
             initialRule = new InitialTimeZoneRule(tzid+UnicodeString(STD_STR), getRawOffset(), 0);
+            if (initialRule == NULL) {
+                status = U_MEMORY_ALLOCATION_ERROR;
+                deleteTransitionRules();
+                return;
+            }
             firstTransition = new TimeZoneTransition(firstDstStart, *initialRule, *dstRule);
         }
-        // Check for null pointers.
-        if (initialRule == NULL || firstTransition == NULL) {
+        if (firstTransition == NULL) {
             status = U_MEMORY_ALLOCATION_ERROR;
             deleteTransitionRules();
             return;