From 1ba59ed70ae60c2b35b05a7416312af418c84fae Mon Sep 17 00:00:00 2001 From: Charles Ferguson Date: Sat, 15 Jan 2022 17:45:45 +0000 Subject: [PATCH] Clear Python pending hook exception before we enter the emulation. The pending exception hook is set when the hook raised an exception and wants to report it outside the emulation loop. However, it is never cleared back to None. This means that after an exception is raised in a hook, all subsequent execution (even if successful) will raise the exception. This change clears the exception before we start another emulation, which should ensure that if we have _hook_exception set, it really is from hooks in this emulation run. --- bindings/python/unicorn/unicorn.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bindings/python/unicorn/unicorn.py b/bindings/python/unicorn/unicorn.py index c929c23c..dcbd2cf3 100644 --- a/bindings/python/unicorn/unicorn.py +++ b/bindings/python/unicorn/unicorn.py @@ -460,6 +460,7 @@ class Uc(object): # emulate from @begin, and stop when reaching address @until def emu_start(self, begin, until, timeout=0, count=0): + self._hook_exception = None status = _uc.uc_emu_start(self._uch, begin, until, timeout, count) if status != uc.UC_ERR_OK: raise UcError(status)