From 190259710eb74e316a6182b90f94ced88d663247 Mon Sep 17 00:00:00 2001 From: Frank Tang Date: Thu, 19 Sep 2024 16:22:06 -0700 Subject: [PATCH] ICU-22730 Fix int32_t overflow in Persian calendar --- icu4c/source/i18n/persncal.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/icu4c/source/i18n/persncal.cpp b/icu4c/source/i18n/persncal.cpp index c97a32197aca..31f7ae252b5e 100644 --- a/icu4c/source/i18n/persncal.cpp +++ b/icu4c/source/i18n/persncal.cpp @@ -217,7 +217,8 @@ int32_t PersianCalendar::handleGetExtendedYear(UErrorCode& status) { * method is called. */ void PersianCalendar::handleComputeFields(int32_t julianDay, UErrorCode& status) { - int64_t daysSinceEpoch = julianDay - PERSIAN_EPOCH; + int64_t daysSinceEpoch = julianDay; + daysSinceEpoch -= PERSIAN_EPOCH; int64_t year = ClockMath::floorDivideInt64( 33LL * daysSinceEpoch + 3LL, 12053LL) + 1LL; if (year > INT32_MAX || year < INT32_MIN) {