mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-08 06:53:45 +00:00
ICU-22633 Fix Hebrew overflow issue
This commit is contained in:
parent
c0c46988c5
commit
e0a711c0a4
3 changed files with 21 additions and 1 deletions
|
@ -2075,7 +2075,12 @@ void Calendar::roll(UCalendarDateFields field, int32_t amount, UErrorCode& statu
|
|||
return;
|
||||
}
|
||||
case UCAL_JULIAN_DAY:
|
||||
set(field, internalGet(field) + amount);
|
||||
if (uprv_add32_overflow(
|
||||
amount, internalGet(field), &amount)) {
|
||||
status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return;
|
||||
}
|
||||
set(field, amount);
|
||||
return;
|
||||
default:
|
||||
// Other fields cannot be rolled by this method
|
||||
|
|
|
@ -195,6 +195,7 @@ void CalendarTest::runIndexedTest( int32_t index, UBool exec, const char* &name,
|
|||
TESTCASE_AUTO(Test22633IndianOverflow);
|
||||
TESTCASE_AUTO(Test22633IslamicUmalquraOverflow);
|
||||
TESTCASE_AUTO(Test22633PersianOverflow);
|
||||
TESTCASE_AUTO(Test22633HebrewOverflow);
|
||||
TESTCASE_AUTO(Test22633AMPMOverflow);
|
||||
|
||||
TESTCASE_AUTO(TestAddOverflow);
|
||||
|
@ -5678,6 +5679,19 @@ void CalendarTest::Test22633PersianOverflow() {
|
|||
UCAL_YEAR, status);
|
||||
assertFalse("Should not return success", U_SUCCESS(status));
|
||||
}
|
||||
|
||||
void CalendarTest::Test22633HebrewOverflow() {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
LocalPointer<Calendar> cal(Calendar::createInstance(Locale("en@calendar=hebrew"), status), status);
|
||||
U_ASSERT(U_SUCCESS(status));
|
||||
cal->clear();
|
||||
cal->roll(UCAL_JULIAN_DAY, -335544321, status);
|
||||
assertTrue("Should return success", U_SUCCESS(status));
|
||||
cal->roll(UCAL_JULIAN_DAY, -1812424430, status);
|
||||
assertEquals("Should return U_ILLEGAL_ARGUMENT_ERROR",
|
||||
U_ILLEGAL_ARGUMENT_ERROR, status);
|
||||
}
|
||||
|
||||
void CalendarTest::Test22633AMPMOverflow() {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
LocalPointer<Calendar> cal(Calendar::createInstance(Locale("en"), status), status);
|
||||
|
|
|
@ -338,6 +338,7 @@ public: // package
|
|||
void Test22633IndianOverflow();
|
||||
void Test22633IslamicUmalquraOverflow();
|
||||
void Test22633PersianOverflow();
|
||||
void Test22633HebrewOverflow();
|
||||
void Test22633AMPMOverflow();
|
||||
|
||||
void verifyFirstDayOfWeek(const char* locale, UCalendarDaysOfWeek expected);
|
||||
|
|
Loading…
Add table
Reference in a new issue