mirror of
https://github.com/yuzu-emu/unicorn
synced 2024-11-24 08:58:18 +00:00
Fix issue #113, untracked reference
This commit is contained in:
parent
5005b4a6e2
commit
8c163706e4
1 changed files with 5 additions and 0 deletions
|
@ -141,6 +141,7 @@ class Uc(object):
|
|||
raise UcError(status)
|
||||
# internal mapping table to save callback & userdata
|
||||
self._callbacks = {}
|
||||
self._ctype_cbs = {}
|
||||
self._callback_count = 0
|
||||
|
||||
|
||||
|
@ -261,6 +262,7 @@ class Uc(object):
|
|||
# save callback & user_data
|
||||
self._callback_count += 1
|
||||
self._callbacks[self._callback_count] = (callback, user_data)
|
||||
cb = None
|
||||
|
||||
if htype in (UC_HOOK_BLOCK, UC_HOOK_CODE):
|
||||
begin = ctypes.c_uint64(arg1)
|
||||
|
@ -293,6 +295,9 @@ class Uc(object):
|
|||
status = _uc.uc_hook_add(self._uch, ctypes.byref(_h2), htype, \
|
||||
cb, ctypes.cast(self._callback_count, ctypes.c_void_p))
|
||||
|
||||
# save the ctype function so gc will leave it alone.
|
||||
self._ctype_cbs[self._callback_count] = cb
|
||||
|
||||
if status != UC_ERR_OK:
|
||||
raise UcError(status)
|
||||
|
||||
|
|
Loading…
Reference in a new issue