mirror of
https://github.com/golang/go
synced 2024-11-02 11:50:30 +00: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:
parent
7f0622e66d
commit
c29cd8abb9
2 changed files with 21 additions and 1 deletions
|
@ -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
|
||||
`,
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue