1
0
mirror of https://github.com/golang/go synced 2024-11-22 03:44:39 -07:00

Prevent Printf crashing when giving an extra nil argument.

R=rsc, r
CC=golang-dev
https://golang.org/cl/1195041
This commit is contained in:
Roger Peppe 2010-05-13 12:49:48 -07:00 committed by Rob Pike
parent e0bde8cfe8
commit 14e04f4d40

View File

@ -1053,8 +1053,10 @@ func (p *pp) doprintf(format string, a []interface{}) {
p.buf.Write(extraBytes)
for ; fieldnum < len(a); fieldnum++ {
field := a[fieldnum]
p.buf.WriteString(reflect.Typeof(field).String())
p.buf.WriteByte('=')
if field != nil {
p.buf.WriteString(reflect.Typeof(field).String())
p.buf.WriteByte('=')
}
p.printField(field, false, false, 0)
if fieldnum+1 < len(a) {
p.buf.Write(commaSpaceBytes)