-
-
Notifications
You must be signed in to change notification settings - Fork 742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ICU-22513 Return error if days is too large in IslamicUmalquraCalendar #2680
ICU-22513 Return error if days is too large in IslamicUmalquraCalendar #2680
Conversation
75afd68
to
1f81c58
Compare
Notice: the branch changed across the force-push!
~ Your Friendly Jira-GitHub PR Checker Bot |
If the year is too large it may overflow the int32_t variable and cause slow or infinity loop, return error if the year is too large that the conversion to day may overflow int32_t. Limit the value to max value of int32_t divide by 400.
1f81c58
to
0c8a874
Compare
Notice: the branch changed across the force-push!
~ Your Friendly Jira-GitHub PR Checker Bot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me, but one question about the Java unit test.
cal.clear(); | ||
cal.add(Calendar.YEAR, 1229080905); | ||
cal.roll(Calendar.WEEK_OF_MONTH, 1499050699); | ||
cal.fieldDifference(new Date(0), Calendar.YEAR_WOY); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm missing something, but shouldn't there be some kind of "expect exception to be thrown" logic in this test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Java use long (64 bits) for those value so it will not throw exception with that setting. The test just make sure it will not be infinity loop or time out.
The computation in IslamicUmalquraCalendar is slower than others, if the days is more than 10,000 years from the epoch, we just return error to avoid hang.
Checklist