# # Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. # Add NULL checks for TimeZone::createTimeZoneIDEnumeration calls https://unicode-org.atlassian.net/browse/ICU-12377 --- icu/source/i18n/dtfmtsym.cpp.orig +++ icu/source/i18n/dtfmtsym.cpp @@ -1303,6 +1303,10 @@ do { // dummy do-while tzids = TimeZone::createTimeZoneIDEnumeration(ZONE_SET, nullptr, nullptr, status); + if (tzids == nullptr) { + status = U_MEMORY_ALLOCATION_ERROR; + break; + } rows = tzids->count(status); if (U_FAILURE(status)) { break; --- icu/source/i18n/zonemeta.cpp.orig +++ icu/source/i18n/zonemeta.cpp @@ -486,12 +486,14 @@ u_UCharsToChars(region, regionBuf, 2); StringEnumeration *ids = TimeZone::createTimeZoneIDEnumeration(UCAL_ZONE_TYPE_CANONICAL_LOCATION, regionBuf, nullptr, status); - int32_t idsLen = ids->count(status); - if (U_SUCCESS(status) && idsLen == 1) { - // only the single zone is available for the region - singleZone = true; + if (ids != nullptr) { + int32_t idsLen = ids->count(status); + if (U_SUCCESS(status) && idsLen == 1) { + // only the single zone is available for the region + singleZone = true; + } + delete ids; } - delete ids; // Cache the result umtx_lock(&gZoneMetaLock);