From: Shane Carr Date: Fri, 23 Jun 2017 00:08:34 +0000 (+0000) Subject: ICU-13177 Merging trunk to branch X-Git-Tag: release-60-rc~98^2~42 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5f631570ebf0dea837103c13e5b2182d19b7a4ab;p=icu ICU-13177 Merging trunk to branch X-SVN-Rev: 40195 --- 5f631570ebf0dea837103c13e5b2182d19b7a4ab diff --cc icu4c/source/i18n/nfrs.cpp index ea4a05d749d,74ce27a401a..6438089c9d7 --- a/icu4c/source/i18n/nfrs.cpp +++ b/icu4c/source/i18n/nfrs.cpp @@@ -835,20 -834,13 +835,20 @@@ uint64_t util64_pow(uint32_t base, uint if (base == 0) { return 0; } - int64_t result = 1; - int64_t pow = base; + uint64_t result = 1; + uint64_t pow = base; - while (exponent > 0) { - if ((exponent & 1) == 1) { + UBool safe = TRUE; + while (exponent > 0) { + U_ASSERT(safe); + if ((exponent & 1) == 1) { result *= pow; } - pow *= pow; + if (pow >= 0x100000000L) { + // The next step will push us out of bounds + safe = FALSE; + } else { + pow *= pow; + } exponent >>= 1; } return result;