Skip to content
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

Avoid potential int overflow #1271

Conversation

ccleva
Copy link
Contributor

@ccleva ccleva commented Jan 3, 2025

Thanks for contributing.

Description

Avoid potential int overflow in PackedLocalDate.plusYears

Testing

No

@@ -362,7 +362,7 @@ public static int plusYears(int yearsToAdd, int packedDate) {
byte m = getMonthValue(packedDate);
short y = getYear(packedDate);

int newYear = YEAR.checkValidIntValue(yearsToAdd + y);
int newYear = YEAR.checkValidIntValue((long)yearsToAdd + y);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int newYear = YEAR.checkValidIntValue((long)yearsToAdd + y);
int newYear = YEAR.checkValidIntValue((long) yearsToAdd + y);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ccleva if you allow edits from maintainers I could merge this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I completely missed that option, will do thanks

Copy link
Contributor Author

@ccleva ccleva Jan 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This option is not available for PR from an organization repo... https://github.com/orgs/community/discussions/5634.

I'll switch back to working with a personal fork when possible

@benmccann benmccann merged commit 541d90f into jtablesaw:master Jan 3, 2025
7 checks passed
@ccleva ccleva deleted the avoid_potential_int_overflow_in_PackedLocalDate branch January 3, 2025 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants