Skip to content

Fix: peekNumber rejects some numerals like 2^64 + "0"#3034

Merged
eamonnmcmanus merged 2 commits into
google:mainfrom
ogolberg:fix/peek-number-overflow-to-zero
Jun 4, 2026
Merged

Fix: peekNumber rejects some numerals like 2^64 + "0"#3034
eamonnmcmanus merged 2 commits into
google:mainfrom
ogolberg:fix/peek-number-overflow-to-zero

Conversation

@ogolberg

@ogolberg ogolberg commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Issue: the "leading zero" logic in peekNumber, which tries to reject octal representations, does not account for long overflows. This results in valid numeric literals like "184467440737095516160" (2^64 + "0") being rejected in STRICT parsing mode.

The easiest way to reproduce this is to serialize and deserialize a BigInteger with the value above.

This is a minimal fix which adds an overflow check to the leading zero condition.

ogolberg added 2 commits June 4, 2026 11:50
Issue: the "leading zero" logic in peekNumber, which tries to reject octal representations,
does not account for long overflows. This results in valid numeric literals
like "184467440737095516160" (2^64 + "0") being rejected in STRICT parsing mode.

The easiest way to reproduce this is to serialize and deserialize a BigInteger with the
value above.

This is a minimal fix which adds an overflow check to the leading zero condition.

@eamonnmcmanus eamonnmcmanus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, that's a great catch!

@eamonnmcmanus eamonnmcmanus merged commit 004e7a4 into google:main Jun 4, 2026
20 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