From: Ian Lance Taylor Date: Tue, 2 Feb 2016 21:23:32 +0000 (-0800) Subject: cmd/vet: don't crash in cgo checker if type is unknown X-Git-Tag: go1.6rc2~1^2~3 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=182a9db2dc57ec7da98391f8955d43b2e07fd40e;p=gostls13.git cmd/vet: don't crash in cgo checker if type is unknown Fixes #14201. Change-Id: Ib61f8c00cae72463f59b90ae199fbdc1e7422a79 Reviewed-on: https://go-review.googlesource.com/19174 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Michael Hudson-Doyle Reviewed-by: Brad Fitzpatrick Reviewed-by: Russ Cox --- diff --git a/src/cmd/vet/cgo.go b/src/cmd/vet/cgo.go index 8807952b48..1985a86fe0 100644 --- a/src/cmd/vet/cgo.go +++ b/src/cmd/vet/cgo.go @@ -72,6 +72,9 @@ func cgoBaseType(f *File, arg ast.Expr) types.Type { } // Here arg is *f(v). t := f.pkg.types[call.Fun].Type + if t == nil { + break + } ptr, ok := t.Underlying().(*types.Pointer) if !ok { break diff --git a/src/cmd/vet/testdata/cgo2.go b/src/cmd/vet/testdata/cgo2.go new file mode 100644 index 0000000000..276aea9619 --- /dev/null +++ b/src/cmd/vet/testdata/cgo2.go @@ -0,0 +1,9 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Test the cgo checker on a file that doesn't use cgo. + +package testdata + +var _ = C.f(*p(**p))