go: fix uc_free, free uc_mem_regions pointer

This commit is contained in:
Ryan Hileman 2017-01-10 16:44:03 -05:00
parent bc569f5a54
commit ab3828222a
2 changed files with 3 additions and 1 deletions

View file

@ -2,6 +2,7 @@ package unicorn
import (
"runtime"
"unsafe"
)
// #include <unicorn/unicorn.h>
@ -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

View file

@ -178,6 +178,7 @@ func (u *uc) MemRegions() ([]*MemRegion, error) {
Prot: int(v.perms),
}
}
C.uc_free(unsafe.Pointer(regions))
return ret, nil
}