mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-02-25 20:26:52 +00:00
Fix issue #113, untracked reference
This commit is contained in:
parent
5005b4a6e2
commit
8c163706e4
|
@ -141,6 +141,7 @@ class Uc(object):
|
||||||
raise UcError(status)
|
raise UcError(status)
|
||||||
# internal mapping table to save callback & userdata
|
# internal mapping table to save callback & userdata
|
||||||
self._callbacks = {}
|
self._callbacks = {}
|
||||||
|
self._ctype_cbs = {}
|
||||||
self._callback_count = 0
|
self._callback_count = 0
|
||||||
|
|
||||||
|
|
||||||
|
@ -261,6 +262,7 @@ class Uc(object):
|
||||||
# save callback & user_data
|
# save callback & user_data
|
||||||
self._callback_count += 1
|
self._callback_count += 1
|
||||||
self._callbacks[self._callback_count] = (callback, user_data)
|
self._callbacks[self._callback_count] = (callback, user_data)
|
||||||
|
cb = None
|
||||||
|
|
||||||
if htype in (UC_HOOK_BLOCK, UC_HOOK_CODE):
|
if htype in (UC_HOOK_BLOCK, UC_HOOK_CODE):
|
||||||
begin = ctypes.c_uint64(arg1)
|
begin = ctypes.c_uint64(arg1)
|
||||||
|
@ -293,6 +295,9 @@ class Uc(object):
|
||||||
status = _uc.uc_hook_add(self._uch, ctypes.byref(_h2), htype, \
|
status = _uc.uc_hook_add(self._uch, ctypes.byref(_h2), htype, \
|
||||||
cb, ctypes.cast(self._callback_count, ctypes.c_void_p))
|
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:
|
if status != UC_ERR_OK:
|
||||||
raise UcError(status)
|
raise UcError(status)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue