diff --git a/intl/icu-patches/bug-1706949-wasi-workaround.diff b/intl/icu-patches/bug-1706949-wasi-workaround.diff index 668373b4d8f7..3ac1815b0c2c 100644 --- a/intl/icu-patches/bug-1706949-wasi-workaround.diff +++ b/intl/icu-patches/bug-1706949-wasi-workaround.diff @@ -3,7 +3,7 @@ # WASI issue: https://github.com/WebAssembly/wasi-sdk/issues/180 diff --git a/intl/icu/source/common/putilimp.h b/intl/icu/source/common/putilimp.h -index d9c90cf4e756..410770aa7c0d 100644 +index 5b95a68..7097232 100644 --- a/intl/icu/source/common/putilimp.h +++ b/intl/icu/source/common/putilimp.h @@ -103,6 +103,8 @@ typedef size_t uintptr_t; @@ -34,7 +34,7 @@ index d9c90cf4e756..410770aa7c0d 100644 # define U_TZNAME tzname #endif diff --git a/intl/icu/source/common/umapfile.h b/intl/icu/source/common/umapfile.h -index 92bd567a2a98..4ed1112bc6df 100644 +index 92bd567..4ed1112 100644 --- a/intl/icu/source/common/umapfile.h +++ b/intl/icu/source/common/umapfile.h @@ -41,6 +41,8 @@ U_CFUNC void uprv_unmapFile(UDataMemory *pData); @@ -47,7 +47,7 @@ index 92bd567a2a98..4ed1112bc6df 100644 # define MAP_IMPLEMENTATION MAP_WIN32 #elif U_HAVE_MMAP || U_PLATFORM == U_PF_OS390 diff --git a/intl/icu/source/common/umutex.cpp b/intl/icu/source/common/umutex.cpp -index ccbee9960a39..6c3452ca1bea 100644 +index ccbee99..6c3452c 100644 --- a/intl/icu/source/common/umutex.cpp +++ b/intl/icu/source/common/umutex.cpp @@ -43,6 +43,7 @@ U_NAMESPACE_BEGIN @@ -173,7 +173,7 @@ index ccbee9960a39..6c3452ca1bea 100644 U_NAMESPACE_END diff --git a/intl/icu/source/common/umutex.h b/intl/icu/source/common/umutex.h -index 2503aa4a2914..49c348444703 100644 +index 8d76b3f..c1a58db 100644 --- a/intl/icu/source/common/umutex.h +++ b/intl/icu/source/common/umutex.h @@ -20,9 +20,12 @@ @@ -244,7 +244,7 @@ index 2503aa4a2914..49c348444703 100644 /************************************************************************************************* * -@@ -231,17 +261,25 @@ public: +@@ -231,17 +261,25 @@ class U_COMMON_API UMutex { // requirements for C++ BasicLockable, allows UMutex to work with std::lock_guard void lock() { @@ -271,7 +271,7 @@ index 2503aa4a2914..49c348444703 100644 /** All initialized UMutexes are kept in a linked list, so that they can be found, * and the underlying std::mutex destructed, by u_cleanup(). -@@ -253,7 +291,9 @@ private: +@@ -253,7 +291,9 @@ class U_COMMON_API UMutex { * Initial fast check is inline, in lock(). The returned value may never * be nullptr. */ @@ -282,7 +282,7 @@ index 2503aa4a2914..49c348444703 100644 diff --git a/intl/icu/source/common/unifiedcache.cpp b/intl/icu/source/common/unifiedcache.cpp -index f2dd91655958..c483ce143cd3 100644 +index 493ab79..a13eed8 100644 --- a/intl/icu/source/common/unifiedcache.cpp +++ b/intl/icu/source/common/unifiedcache.cpp @@ -13,15 +13,19 @@ @@ -440,7 +440,7 @@ index f2dd91655958..c483ce143cd3 100644 void UnifiedCache::_fetch( diff --git a/intl/icu/source/i18n/decContext.h b/intl/icu/source/i18n/decContext.h -index e145777d1e7a..106704b6e76d 100644 +index 59ab65e..20f3526 100644 --- a/intl/icu/source/i18n/decContext.h +++ b/intl/icu/source/i18n/decContext.h @@ -61,7 +61,9 @@ @@ -454,7 +454,7 @@ index e145777d1e7a..106704b6e76d 100644 /* Extended flags setting -- set this to 0 to use only IEEE flags */ #if !defined(DECEXTFLAG) diff --git a/intl/icu/source/i18n/decimfmt.cpp b/intl/icu/source/i18n/decimfmt.cpp -index daa1129a6ab1..c8f1eda62c30 100644 +index daa1129..c8f1eda 100644 --- a/intl/icu/source/i18n/decimfmt.cpp +++ b/intl/icu/source/i18n/decimfmt.cpp @@ -480,8 +480,13 @@ DecimalFormat& DecimalFormat::operator=(const DecimalFormat& rhs) { @@ -547,7 +547,7 @@ index daa1129a6ab1..c8f1eda62c30 100644 void diff --git a/intl/icu/source/i18n/number_mapper.h b/intl/icu/source/i18n/number_mapper.h -index d18b8b3c438c..e5b5e3fd6294 100644 +index 9ecd776..d094289 100644 --- a/intl/icu/source/i18n/number_mapper.h +++ b/intl/icu/source/i18n/number_mapper.h @@ -7,7 +7,6 @@ @@ -569,7 +569,7 @@ index d18b8b3c438c..e5b5e3fd6294 100644 U_NAMESPACE_BEGIN namespace number { namespace impl { -@@ -183,10 +186,18 @@ struct DecimalFormatFields : public UMemory { +@@ -193,10 +196,18 @@ struct DecimalFormatFields : public UMemory { LocalizedNumberFormatter formatter; /** The lazy-computed parser for .parse() */ @@ -589,10 +589,10 @@ index d18b8b3c438c..e5b5e3fd6294 100644 /** Small object ownership warehouse for the formatter and parser */ DecimalFormatWarehouse warehouse; diff --git a/intl/icu/source/i18n/numrange_fluent.cpp b/intl/icu/source/i18n/numrange_fluent.cpp -index 33179026f8d2..ceec51431031 100644 +index f1060b3..66e12ee 100644 --- a/intl/icu/source/i18n/numrange_fluent.cpp +++ b/intl/icu/source/i18n/numrange_fluent.cpp -@@ -239,28 +239,48 @@ LocalizedNumberRangeFormatter::LocalizedNumberRangeFormatter(NFS&& src) U_N +@@ -240,29 +240,49 @@ LocalizedNumberRangeFormatter::LocalizedNumberRangeFormatter(NFS&& src) U_N : NFS(std::move(src)) { // Steal the compiled formatter LNF&& _src = static_cast(src); @@ -607,6 +607,7 @@ index 33179026f8d2..ceec51431031 100644 } LocalizedNumberRangeFormatter& LocalizedNumberRangeFormatter::operator=(const LNF& other) { + if (this == &other) { return *this; } // self-assignment: no-op NFS::operator=(static_cast&>(other)); // Do not steal; just clear +#ifndef __wasi__ @@ -641,7 +642,7 @@ index 33179026f8d2..ceec51431031 100644 } LocalizedNumberRangeFormatter::LocalizedNumberRangeFormatter(const RangeMacroProps& macros, const Locale& locale) { -@@ -344,7 +364,11 @@ LocalizedNumberRangeFormatter::getFormatter(UErrorCode& status) const { +@@ -346,7 +366,11 @@ LocalizedNumberRangeFormatter::getFormatter(UErrorCode& status) const { } // First try to get the pre-computed formatter @@ -653,7 +654,7 @@ index 33179026f8d2..ceec51431031 100644 if (ptr != nullptr) { return ptr; } -@@ -363,6 +387,7 @@ LocalizedNumberRangeFormatter::getFormatter(UErrorCode& status) const { +@@ -365,6 +389,7 @@ LocalizedNumberRangeFormatter::getFormatter(UErrorCode& status) const { // it is set to what is actually stored in the atomic // if another thread beat us to computing the formatter object. auto* nonConstThis = const_cast(this); @@ -661,7 +662,7 @@ index 33179026f8d2..ceec51431031 100644 if (!nonConstThis->fAtomicFormatter.compare_exchange_strong(ptr, temp)) { // Another thread beat us to computing the formatter delete temp; -@@ -371,6 +396,10 @@ LocalizedNumberRangeFormatter::getFormatter(UErrorCode& status) const { +@@ -373,6 +398,10 @@ LocalizedNumberRangeFormatter::getFormatter(UErrorCode& status) const { // Our copy of the formatter got stored in the atomic return temp; } @@ -673,7 +674,7 @@ index 33179026f8d2..ceec51431031 100644 } diff --git a/intl/icu/source/i18n/unicode/numberrangeformatter.h b/intl/icu/source/i18n/unicode/numberrangeformatter.h -index 4d436a769453..5adb09285797 100644 +index b9a4600..0ba2fa0 100644 --- a/intl/icu/source/i18n/unicode/numberrangeformatter.h +++ b/intl/icu/source/i18n/unicode/numberrangeformatter.h @@ -10,7 +10,6 @@ @@ -695,7 +696,7 @@ index 4d436a769453..5adb09285797 100644 /** * \file * \brief C++ API: Library for localized formatting of number, currency, and unit ranges. -@@ -194,7 +197,9 @@ class NumberRangeFormatterImpl; +@@ -77,7 +80,9 @@ struct UFormattedNumberRangeImpl; } // namespace icu::number U_NAMESPACE_END @@ -705,7 +706,7 @@ index 4d436a769453..5adb09285797 100644 U_NAMESPACE_BEGIN namespace number { // icu::number -@@ -663,7 +668,11 @@ class U_I18N_API LocalizedNumberRangeFormatter +@@ -546,7 +551,11 @@ class U_I18N_API LocalizedNumberRangeFormatter ~LocalizedNumberRangeFormatter(); private: diff --git a/intl/icu-patches/bug-1714933-1-locale-unicode-keywords.diff b/intl/icu-patches/bug-1714933-1-locale-unicode-keywords.diff new file mode 100644 index 000000000000..40630b707be7 --- /dev/null +++ b/intl/icu-patches/bug-1714933-1-locale-unicode-keywords.diff @@ -0,0 +1,29 @@ +# https://unicode-org.atlassian.net/browse/ICU-21539 +# +# https://github.com/unicode-org/icu/commit/45b893c1f9af9e541b8812c2073471e134aaf773.diff + +diff --git a/intl/icu/source/common/locid.cpp b/intl/icu/source/common/locid.cpp +index 4fec17d14fd..02cd82a7b8e 100644 +--- a/intl/icu/source/common/locid.cpp ++++ b/intl/icu/source/common/locid.cpp +@@ -2515,16 +2515,16 @@ class UnicodeKeywordEnumeration : public KeywordEnumeration { + + virtual const char* next(int32_t* resultLength, UErrorCode& status) { + const char* legacy_key = KeywordEnumeration::next(nullptr, status); +- if (U_SUCCESS(status) && legacy_key != nullptr) { ++ while (U_SUCCESS(status) && legacy_key != nullptr) { + const char* key = uloc_toUnicodeLocaleKey(legacy_key); +- if (key == nullptr) { +- status = U_ILLEGAL_ARGUMENT_ERROR; +- } else { ++ if (key != nullptr) { + if (resultLength != nullptr) { + *resultLength = static_cast(uprv_strlen(key)); + } + return key; + } ++ // Not a Unicode keyword, could be a t, x or other, continue to look at the next one. ++ legacy_key = KeywordEnumeration::next(nullptr, status); + } + if (resultLength != nullptr) *resultLength = 0; + return nullptr; diff --git a/intl/icu-patches/bug-1714933-2-locale-basename-memory-leak.diff b/intl/icu-patches/bug-1714933-2-locale-basename-memory-leak.diff new file mode 100644 index 000000000000..c6f14fa46e84 --- /dev/null +++ b/intl/icu-patches/bug-1714933-2-locale-basename-memory-leak.diff @@ -0,0 +1,39 @@ +# https://unicode-org.atlassian.net/browse/ICU-21587 +# +# https://github.com/unicode-org/icu/commit/2dc5bea9061b4fb05cd03e21b775dd944a0eb81d.diff + +diff --git a/intl/icu/source/common/locid.cpp b/intl/icu/source/common/locid.cpp +index 02cd82a7b8e..3c6e5b06690 100644 +--- a/intl/icu/source/common/locid.cpp ++++ b/intl/icu/source/common/locid.cpp +@@ -469,14 +469,18 @@ Locale& Locale::operator=(Locale&& other) U_NOEXCEPT { + if ((baseName != fullName) && (baseName != fullNameBuffer)) uprv_free(baseName); + if (fullName != fullNameBuffer) uprv_free(fullName); + +- if (other.fullName == other.fullNameBuffer) { ++ if (other.fullName == other.fullNameBuffer || other.baseName == other.fullNameBuffer) { + uprv_strcpy(fullNameBuffer, other.fullNameBuffer); ++ } ++ if (other.fullName == other.fullNameBuffer) { + fullName = fullNameBuffer; + } else { + fullName = other.fullName; + } + +- if (other.baseName == other.fullName) { ++ if (other.baseName == other.fullNameBuffer) { ++ baseName = fullNameBuffer; ++ } else if (other.baseName == other.fullName) { + baseName = fullName; + } else { + baseName = other.baseName; +@@ -2681,6 +2685,9 @@ Locale::setKeywordValue(const char* keywordName, const char* keywordValue, UErro + if (fullName != fullNameBuffer) { + // if full Name is already on the heap, need to free it. + uprv_free(fullName); ++ if (baseName == fullName) { ++ baseName = newFullName; // baseName should not point to freed memory. ++ } + } + fullName = newFullName; + status = U_ZERO_ERROR; diff --git a/intl/icu-patches/bug-1714933-3-locale-nullptr-deref.diff b/intl/icu-patches/bug-1714933-3-locale-nullptr-deref.diff new file mode 100644 index 000000000000..14aa7e04d50b --- /dev/null +++ b/intl/icu-patches/bug-1714933-3-locale-nullptr-deref.diff @@ -0,0 +1,29 @@ +# https://unicode-org.atlassian.net/browse/ICU-21597 +# +# https://github.com/unicode-org/icu/commit/b13be666cd354c4ff177906d779273d7cfc155c0.diff + +diff --git a/intl/icu/source/common/locid.cpp b/intl/icu/source/common/locid.cpp +index 3c6e5b06690..4b7d21ee13d 100644 +--- a/intl/icu/source/common/locid.cpp ++++ b/intl/icu/source/common/locid.cpp +@@ -1571,6 +1571,7 @@ AliasReplacer::replaceTransformedExtensions( + const char* tvalue = uprv_strchr(tkey, '-'); + if (tvalue == nullptr) { + status = U_ILLEGAL_ARGUMENT_ERROR; ++ return false; + } + const char* nextTKey = ultag_getTKeyStart(tvalue); + if (nextTKey != nullptr) { +@@ -1591,8 +1592,11 @@ AliasReplacer::replaceTransformedExtensions( + } + const char* tfield = (const char*) tfields.elementAt(i); + const char* tvalue = uprv_strchr(tfield, '-'); ++ if (tvalue == nullptr) { ++ status = U_ILLEGAL_ARGUMENT_ERROR; ++ return false; ++ } + // Split the "tkey-tvalue" pair string so that we can canonicalize the tvalue. +- U_ASSERT(tvalue != nullptr); + *((char*)tvalue++) = '\0'; // NULL terminate tkey + output.append(tfield, status).append('-', status); + const char* bcpTValue = ulocimp_toBcpType(tfield, tvalue, nullptr, nullptr); diff --git a/intl/update-icu.sh b/intl/update-icu.sh index 9c6f1c192575..93c82ba4f38c 100755 --- a/intl/update-icu.sh +++ b/intl/update-icu.sh @@ -58,6 +58,9 @@ for patch in \ bug-1636984-display-name-fractional-seconds.diff \ bug-1636984-append-item-dayperiod-fractional-seconds.diff \ bug-1706949-wasi-workaround.diff \ + bug-1714933-1-locale-unicode-keywords.diff \ + bug-1714933-2-locale-basename-memory-leak.diff \ + bug-1714933-3-locale-nullptr-deref.diff \ ; do echo "Applying local patch $patch" patch -d ${icu_dir}/../../ -p1 --no-backup-if-mismatch < ${icu_dir}/../icu-patches/$patch