From d39c20acfe8b6558b7416bfc04ced860187b097f Mon Sep 17 00:00:00 2001 From: Ryan Hileman Date: Thu, 11 May 2017 19:39:04 -0700 Subject: [PATCH] Go: fix NewRegBatch([]int{}) (#831) --- bindings/go/unicorn/reg_batch.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bindings/go/unicorn/reg_batch.go b/bindings/go/unicorn/reg_batch.go index 120c9a0e..f5f6c8d4 100644 --- a/bindings/go/unicorn/reg_batch.go +++ b/bindings/go/unicorn/reg_batch.go @@ -46,7 +46,11 @@ func regBatchSetup(regs []int) (buf unsafe.Pointer, vals []uint64, cenums *C.int enums[i] = C.int(regs[i]) } var cvals *C.uint64_t - buf = C.reg_batch_setup((*C.int)(unsafe.Pointer(&enums[0])), C.int(len(regs)), &cvals, &cenums, &crefs) + var inEnums *C.int + if len(regs) > 0 { + inEnums = (*C.int)(unsafe.Pointer(&enums[0])) + } + buf = C.reg_batch_setup(inEnums, C.int(len(regs)), &cvals, &cenums, &crefs) vals = (*[1 << 24]uint64)(unsafe.Pointer(cvals))[:len(regs)] return }