diff options
author | Adam Langley <agl@golang.org> | 2011-04-08 15:43:19 -0400 |
---|---|---|
committer | Adam Langley <agl@golang.org> | 2011-04-08 15:43:19 -0400 |
commit | 8fc67033914902065b6150fc6f0808b00dbe05b5 (patch) | |
tree | c6a178039b1210456e61fd7e81208bb9eb37d6fa | |
parent | 23f6479be645761c5ba7ba92cf062bbc6470065d (diff) | |
download | go-8fc67033914902065b6150fc6f0808b00dbe05b5.tar.gz go-8fc67033914902065b6150fc6f0808b00dbe05b5.zip |
big: don't crash when printing nil ints
"%#v" of a structure with *big.Int's tends to crash a lot otherwise.
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/4382044
-rwxr-xr-x | src/pkg/big/int.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/pkg/big/int.go b/src/pkg/big/int.go index ecd70e03ef..f1ea7b1c2e 100755 --- a/src/pkg/big/int.go +++ b/src/pkg/big/int.go @@ -337,6 +337,10 @@ func fmtbase(ch int) int { // 'x' (hexadecimal). // func (x *Int) Format(s fmt.State, ch int) { + if x == nil { + fmt.Fprint(s, "<nil>") + return + } if x.neg { fmt.Fprint(s, "-") } |