Skip to content

Commit 48cc878

Browse files
committed
ICU-22730 Fix int32_t overflow in Persian calendar
1 parent b3bf9f8 commit 48cc878

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

icu4c/source/i18n/persncal.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ int32_t PersianCalendar::handleGetExtendedYear(UErrorCode& status) {
217217
* method is called.
218218
*/
219219
void PersianCalendar::handleComputeFields(int32_t julianDay, UErrorCode& status) {
220-
int64_t daysSinceEpoch = julianDay - PERSIAN_EPOCH;
220+
int64_t daysSinceEpoch = julianDay;
221+
daysSinceEpoch -= PERSIAN_EPOCH;
221222
int64_t year = ClockMath::floorDivideInt64(
222223
33LL * daysSinceEpoch + 3LL, 12053LL) + 1LL;
223224
if (year > INT32_MAX || year < INT32_MIN) {

0 commit comments

Comments
 (0)