Repository navigation
Fix JSON integer overflow decoding as MaxInt64 - #486
Merged
Merged
Conversation
ParseInt reports ErrRange and also returns the extreme int64. The JSON decoder dropped that error, so 9223372036854775808 decoded as 9223372036854775807.
geseq
approved these changes
Oct 3, 2026
Collaborator
|
Thanks for the PR. LGTM |
Contributor
Author
|
Thanks, glad this landed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
json.Decodeof an integer pastMaxInt64returned that extreme value and a nil error.ParseIntreportsErrRangeand also returnsMaxInt64orMinInt64. The decoder dropped the error.9223372036854775808decoded as9223372036854775807.-9223372036854775809decoded as-9223372036854775808. Both are now errors.9223372036854775807and-9223372036854775808still decode as those integers.1.5is still a float.Test plan
go test -count=1 ./stdlib/json/go test -count=1 ./...TestDecodeIntOverflowfailed on master before the change (nil error) and passes after it.