diff options
Diffstat (limited to 'src/math/big/ratconv.go')
-rw-r--r-- | src/math/big/ratconv.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/math/big/ratconv.go b/src/math/big/ratconv.go index ac3c8bd11f..90053a9c81 100644 --- a/src/math/big/ratconv.go +++ b/src/math/big/ratconv.go @@ -169,6 +169,11 @@ func (z *Rat) SetString(s string) (*Rat, bool) { n := exp5 if n < 0 { n = -n + if n < 0 { + // This can occur if -n overflows. -(-1 << 63) would become + // -1 << 63, which is still negative. + return nil, false + } } if n > 1e6 { return nil, false // avoid excessively large exponents |