]> Cypherpunks repositories - gostls13.git/commitdiff
go/doc: skip examples with no body
authorMuhammad Falak R Wani <falakreyaz@gmail.com>
Sat, 6 Oct 2018 13:46:28 +0000 (19:16 +0530)
committerRobert Griesemer <gri@golang.org>
Tue, 9 Oct 2018 19:41:35 +0000 (19:41 +0000)
Fixes #28044

Change-Id: I0052e078dd34dc3546204416bcc5a99e3146c535
Reviewed-on: https://go-review.googlesource.com/c/140317
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/go/doc/example.go

index 5b40bb0fb25fb0eb78599342220c9eb3f9658c9d..d6d4ece3a8e39b0e42611c86a7f776e0b6daf3ac 100644 (file)
@@ -68,6 +68,9 @@ func Examples(files ...*ast.File) []*Example {
                        if !isTest(name, "Example") {
                                continue
                        }
+                       if f.Body == nil { // ast.File.Body nil dereference (see issue 28044)
+                               continue
+                       }
                        var doc string
                        if f.Doc != nil {
                                doc = f.Doc.Text()