mirror of
https://github.com/Cxbx-Reloaded/unicorn.git
synced 2024-11-23 19:39:50 +00:00
Merge pull request #712 from lunixbochs/go-free-regions
go: fix uc_free, free uc_mem_regions pointer
This commit is contained in:
commit
6378db99dc
@ -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
|
||||
|
@ -178,6 +178,7 @@ func (u *uc) MemRegions() ([]*MemRegion, error) {
|
||||
Prot: int(v.perms),
|
||||
}
|
||||
}
|
||||
C.uc_free(unsafe.Pointer(regions))
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user