From e2036424c12fa65e76926a6ae953624218ec4cc7 Mon Sep 17 00:00:00 2001 From: Ryan Hileman Date: Sat, 29 Aug 2015 08:32:58 -0700 Subject: [PATCH] improve Go binding safety --- bindings/go/unicorn/unicorn.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bindings/go/unicorn/unicorn.go b/bindings/go/unicorn/unicorn.go index f2e925f9..04f161c0 100644 --- a/bindings/go/unicorn/unicorn.go +++ b/bindings/go/unicorn/unicorn.go @@ -72,10 +72,16 @@ func (u *Uc) RegRead(reg int) (uint64, error) { } func (u *Uc) MemWrite(addr uint64, data []byte) error { + if len(data) == 0 { + return nil + } return errReturn(C.uc_mem_write(u.Handle, C.uint64_t(addr), (*C.uint8_t)(unsafe.Pointer(&data[0])), C.size_t(len(data)))) } func (u *Uc) MemReadInto(dst []byte, addr uint64) error { + if len(dst) == 0 { + return nil + } return errReturn(C.uc_mem_read(u.Handle, C.uint64_t(addr), (*C.uint8_t)(unsafe.Pointer(&dst[0])), C.size_t(len(dst)))) }