Skip to content

Convert string to int64 with ParseInt to prevent overflow on 32-bit systems #21

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Pippadi
Copy link

@Pippadi Pippadi commented May 3, 2022

strconv.Atoi returns an int, which isn't guaranteed to be 64-bit on all platforms. To prevent ints from overflowing on 32-bit platforms when setting int64 fields, strconv.ParseInt is used instead.

@hinshun
Copy link
Contributor

hinshun commented May 3, 2022

Thanks @Pippadi, can we add a test of some sort?

@Pippadi
Copy link
Author

Pippadi commented May 4, 2022

Just added to TestUnmarshal. Passes with GOARCH=386 go test.
Is this what you were looking for?

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