1
0
mirror of https://github.com/golang/go synced 2024-11-20 02:14:46 -07:00

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
This commit is contained in:
Adam Langley 2011-04-08 15:43:19 -04:00
parent 23f6479be6
commit 8fc6703391

View File

@ -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, "-")
}