Skip to content

Commit

Permalink
ICU-22730 Fix int32_t overflow in Persian calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankYFTang committed Sep 20, 2024
1 parent b3bf9f8 commit 48cc878
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion icu4c/source/i18n/persncal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 48cc878

Please sign in to comment.