]> Cypherpunks repositories - gostls13.git/commitdiff
big: don't crash when printing nil ints
authorAdam Langley <agl@golang.org>
Fri, 8 Apr 2011 19:43:19 +0000 (15:43 -0400)
committerAdam Langley <agl@golang.org>
Fri, 8 Apr 2011 19:43:19 +0000 (15:43 -0400)
"%#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

src/pkg/big/int.go

index ecd70e03ef10b954c6a011d5c6408839d24e9f7b..f1ea7b1c2ec2cf8c524dc444f541b4f276928ec7 100755 (executable)
@@ -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, "-")
        }