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

Prevent potential overflow #41

Merged
merged 1 commit into from
Mar 19, 2024
Merged

Prevent potential overflow #41

merged 1 commit into from
Mar 19, 2024

Conversation

backink
Copy link
Contributor

@backink backink commented Mar 19, 2024

Cast a 64 bit integer into 32 bit might cause overflow. When the *a is larger than *b and the 31th bit of (*a - *b) is 1, casting it to an 32 bit integer will yeild a negative number, which is an unexpected result.

Cast a 64 bit integer into 32 bit might cause overflow.
When the *a is larger than *b and 31th bit of (*a - *b) is 1,
casting it to an 32 bit integer will yeild a negative number,
which is an unexpected result.
@oreparaz
Copy link
Owner

Thanks! You're right, nasty cast! Appreciated 👍

@oreparaz oreparaz merged commit dc26965 into oreparaz:master Mar 19, 2024
5 checks passed
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