Skip to content

Commit

Permalink
ICU-20079 int overflow in Gregorian Calendar. (unicode-org#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
aheninger authored Aug 24, 2018
1 parent 812798f commit bc6e899
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions icu4c/source/i18n/gregocal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,8 @@ int32_t GregorianCalendar::handleComputeMonthStart(int32_t eyear, int32_t month,
}

UBool isLeap = eyear%4 == 0;
int32_t y = eyear-1;
int32_t julianDay = 365*y + ClockMath::floorDivide(y, 4) + (kJan1_1JulianDay - 3);
int64_t y = (int64_t)eyear-1;
int64_t julianDay = 365*y + ClockMath::floorDivide(y, (int64_t)4) + (kJan1_1JulianDay - 3);

nonConstThis->fIsGregorian = (eyear >= fGregorianCutoverYear);
#if defined (U_DEBUG_CAL)
Expand Down
4 changes: 2 additions & 2 deletions icu4c/source/i18n/gregoimp.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ inline int32_t Grego::millisToJulianDay(double millis) {
}

inline int32_t Grego::gregorianShift(int32_t eyear) {
int32_t y = eyear-1;
int32_t gregShift = ClockMath::floorDivide(y, 400) - ClockMath::floorDivide(y, 100) + 2;
int64_t y = (int64_t)eyear-1;
int32_t gregShift = ClockMath::floorDivide(y, (int64_t)400) - ClockMath::floorDivide(y, (int64_t)100) + 2;
return gregShift;
}

Expand Down

0 comments on commit bc6e899

Please sign in to comment.