Skip to content

Fix JSON integer overflow decoding as MaxInt64 - #486

Merged
geseq merged 1 commit into
d5:masterfrom
SashaMIT:fix/json-int-overflow
Oct 3, 2026
Merged

geseq merged 1 commit into
d5:masterfrom
SashaMIT:fix/json-int-overflow

Conversation

@SashaMIT

@SashaMIT SashaMIT commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • json.Decode of an integer past MaxInt64 returned that extreme value and a nil error. ParseInt reports ErrRange and also returns MaxInt64 or MinInt64. The decoder dropped the error.
  • 9223372036854775808 decoded as 9223372036854775807. -9223372036854775809 decoded as -9223372036854775808. Both are now errors.
  • 9223372036854775807 and -9223372036854775808 still decode as those integers. 1.5 is still a float.

Test plan

  • go test -count=1 ./stdlib/json/
  • go test -count=1 ./...
  • TestDecodeIntOverflow failed on master before the change (nil error) and passes after it.

ParseInt reports ErrRange and also returns the extreme int64. The JSON
decoder dropped that error, so 9223372036854775808 decoded as
9223372036854775807.
@geseq

geseq commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the PR. LGTM

@geseq
geseq merged commit 2278784 into d5:master Oct 3, 2026
1 check passed
@SashaMIT

SashaMIT commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, glad this landed.

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