]> Cypherpunks repositories - gostls13.git/commit
cmd/cgo: fix panic on references to non-existing C types
authorDidier Spezia <didier.06@gmail.com>
Sat, 3 Oct 2015 15:50:45 +0000 (15:50 +0000)
committerIan Lance Taylor <iant@golang.org>
Mon, 5 Oct 2015 22:37:07 +0000 (22:37 +0000)
commit9c258c6aa6880268a0be9f2e90ea11f9e4ded150
tree461f0301e83d2d6acdbdf4aff283e647bba2004f
parent4a6326e7b5f326e6079073fb843b4ab096cbf652
cmd/cgo: fix panic on references to non-existing C types

cgo panics in Package.rewriteRef for:

var a = C.enum_test(1)
or
p := new(C.enum_test)

when the corresponding enum type is not defined.

Check nil values for Type fields and issue a proper
error instead.

Fixes #11097
Updates #12160

Change-Id: I5821d29097ef0a36076ec5273125b09846c7d832
Reviewed-on: https://go-review.googlesource.com/15264
Reviewed-by: Ian Lance Taylor <iant@golang.org>
misc/cgo/errors/issue11097a.go [new file with mode: 0644]
misc/cgo/errors/issue11097b.go [new file with mode: 0644]
misc/cgo/errors/test.bash
src/cmd/cgo/gcc.go