Merge pull request #712 from lunixbochs/go-free-regions

go: fix uc_free, free uc_mem_regions pointer
This commit is contained in:
Nguyen Anh Quynh 2017-01-11 09:27:45 +08:00 committed by GitHub
commit 6378db99dc
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
}