diff --git a/go/pointer/gen.go b/go/pointer/gen.go index 12f4d796..48ca3684 100644 --- a/go/pointer/gen.go +++ b/go/pointer/gen.go @@ -525,7 +525,9 @@ func (a *analysis) genBuiltinCall(instr ssa.CallInstruction, cgn *cgnode) { case "print": // In the tests, the probe might be the sole reference // to its arg, so make sure we create nodes for it. - a.valueNode(call.Args[0]) + if len(call.Args) > 0 { + a.valueNode(call.Args[0]) + } case "ssa:wrapnilchk": a.copy(a.valueNode(instr.Value()), a.valueNode(call.Args[0]), 1) diff --git a/go/pointer/pointer_test.go b/go/pointer/pointer_test.go index aeffb5c5..ed3ebb06 100644 --- a/go/pointer/pointer_test.go +++ b/go/pointer/pointer_test.go @@ -191,7 +191,8 @@ func doOneInput(input, filename string) bool { for _, b := range fn.Blocks { for _, instr := range b.Instrs { if instr, ok := instr.(ssa.CallInstruction); ok { - if b, ok := instr.Common().Value.(*ssa.Builtin); ok && b.Name() == "print" { + call := instr.Common() + if b, ok := call.Value.(*ssa.Builtin); ok && b.Name() == "print" && len(call.Args) == 1 { probes[instr.Common()] = true } } diff --git a/go/pointer/testdata/another.go b/go/pointer/testdata/another.go index 443c94d0..12ed690e 100644 --- a/go/pointer/testdata/another.go +++ b/go/pointer/testdata/another.go @@ -31,4 +31,6 @@ func main() { // labels, even though it may contain pointers that do. print(i) // @pointsto makeinterface:func(x int) int | makeinterface:func(x int, y int) | makeinterface:func(int, int) | makeinterface:int | makeinterface:main.S print(i.(func(int) int)) // @pointsto main.incr + + print() // regression test for crash }