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 }