1
0
mirror of https://github.com/golang/go synced 2024-11-22 05:54:40 -07:00

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 fixed := false
for _, d := range f.Decls { for _, d := range f.Decls {
fd, ok := d.(*ast.FuncDecl) fd, ok := d.(*ast.FuncDecl)
if !ok { if !ok || fd.Body == nil {
continue continue
} }
walk(fd.Body, func(n interface{}) { walk(fd.Body, func(n interface{}) {

View File

@ -28,6 +28,26 @@ func f() {
err := x.JoinGroup(nil, gaddr) err := x.JoinGroup(nil, gaddr)
err = y.LeaveGroup(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
`, `,
}, },
} }