Skip to content

fix: limit exponents accepted by NewFromString and UnmarshalBinary - #440

Merged
mwoss merged 2 commits into
masterfrom
fix/max-exponent
Oct 4, 2026
Merged

mwoss merged 2 commits into
masterfrom
fix/max-exponent

Conversation

@mwoss

@mwoss mwoss commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

Fixes #226.

Parsing 1e-1000000000 is fast, but using the result (String, Add, Float64, ...) can hang the process or use gigabytes of memory.

This adds MaxDecodeExponent (default 10,000). NewFromString and UnmarshalBinary now return an error for larger exponents. JSON, text, SQL, gob and Spanner decoding all go through these two functions.

Behavior change: inputs with larger exponents that parsed before now fail. Set MaxDecodeExponent higher at startup if you need them.

Replaces #427.

@mwoss
mwoss merged commit 71ca20d into master Oct 4, 2026
6 checks passed
@mwoss
mwoss deleted the fix/max-exponent branch October 4, 2026 07:37
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.

Float64() taking forever for huge decimal

1 participant