Commit c29cd8ab authored by David Symonds's avatar David Symonds

gofix: avoid panic on body-less functions in netudpgroup.

R=rsc, r
CC=golang-dev
https://golang.org/cl/5347041
parent 7f0622e6
......@@ -30,7 +30,7 @@ func netudpgroup(f *ast.File) bool {
fixed := false
for _, d := range f.Decls {
fd, ok := d.(*ast.FuncDecl)
if !ok {
if !ok || fd.Body == nil {
continue
}
walk(fd.Body, func(n interface{}) {
......
......@@ -28,6 +28,26 @@ func f() {
err := x.JoinGroup(nil, gaddr)
err = y.LeaveGroup(nil, gaddr)
}
`,
},
// Innocent function with no body.
{
Name: "netudpgroup.1",
In: `package main
import "net"
func f()
var _ net.IP
`,
Out: `package main
import "net"
func f()
var _ net.IP
`,
},
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment