From ab3828222af237477fe52f128530ff1cd677b925 Mon Sep 17 00:00:00 2001 From: Ryan Hileman Date: Tue, 10 Jan 2017 16:44:03 -0500 Subject: [PATCH] go: fix uc_free, free uc_mem_regions pointer --- bindings/go/unicorn/context.go | 3 ++- bindings/go/unicorn/unicorn.go | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/bindings/go/unicorn/context.go b/bindings/go/unicorn/context.go index be9fceb9..3e8bcbfe 100644 --- a/bindings/go/unicorn/context.go +++ b/bindings/go/unicorn/context.go @@ -2,6 +2,7 @@ package unicorn import ( "runtime" + "unsafe" ) // #include @@ -17,7 +18,7 @@ func (u *uc) ContextSave(reuse Context) (Context, error) { if err := errReturn(C.uc_context_alloc(u.handle, ctx)); err != nil { return nil, err } - runtime.SetFinalizer(ctx, func(p Context) { C.uc_free(*p) }) + runtime.SetFinalizer(ctx, func(p Context) { C.uc_free(unsafe.Pointer(*p)) }) if err := errReturn(C.uc_context_save(u.handle, *ctx)); err != nil { } return ctx, nil diff --git a/bindings/go/unicorn/unicorn.go b/bindings/go/unicorn/unicorn.go index 96281d0e..c2fc1425 100644 --- a/bindings/go/unicorn/unicorn.go +++ b/bindings/go/unicorn/unicorn.go @@ -178,6 +178,7 @@ func (u *uc) MemRegions() ([]*MemRegion, error) { Prot: int(v.perms), } } + C.uc_free(unsafe.Pointer(regions)) return ret, nil }