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

R=rsc, r
CC=golang-dev
https://golang.org/cl/5347041
This commit is contained in:
David Symonds 2011-11-05 11:28:23 +11:00
parent 7f0622e66d
commit c29cd8abb9
2 changed files with 21 additions and 1 deletions

View file

@ -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{}) {

View file

@ -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
`,
},
}