]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/godoc: fix minor bug in FormatSelections.
authorPaul Chang <paulchang@google.com>
Fri, 28 Sep 2012 21:19:43 +0000 (14:19 -0700)
committerRobert Griesemer <gri@golang.org>
Fri, 28 Sep 2012 21:19:43 +0000 (14:19 -0700)
FormatSelections tries to call a nil function value if lw is nil
and the final entry in the selections array is non-nil. Luckily,
this doesn't actually happen in practice since godoc doesn't use
this combination (no line numbers, but with selections).

R=gri
CC=gobot, golang-dev
https://golang.org/cl/6488106

src/cmd/godoc/format.go

index 3b1b9a8226e775e35487b8953a9ccb27ffed2c66..64f4b80305cd361e0361c5159fd61b01bf9d8b26 100644 (file)
@@ -108,7 +108,7 @@ func FormatSelections(w io.Writer, text []byte, lw LinkWriter, links Selection,
                        break
                }
                // determine the kind of segment change
-               if index == len(selections)-1 {
+               if lw != nil && index == len(selections)-1 {
                        // we have a link segment change:
                        // format the previous selection segment, write the
                        // link tag and start a new selection segment