rainbow
rainbow copied to clipboard
Fix remove_hooks dict iteration
When running tests, the following error is raised:
def remove_hooks(self):
"""Remove all hooked functions."""
> for addr, hook in self.stubbed_functions.items():
E RuntimeError: dictionary changed size during iteration
This is caused by https://github.com/Ledger-Donjon/rainbow/pull/65 (oops).
This PR proposes a trivial patch to fix the issue. With this PR, all tests are now green 🎉
Hello,
Wouldn't it be easier to restore self.stubbed_functions = {}?
def remove_hooks(self):
"""Remove all hooked functions."""
for hook in self.stubbed_functions.values():
self.emu.hook_del(hook)
self.stubbed_functions = {}
(or to use dict.clear?)
Thanks for the review! I updated the patch with .clear() which seems cleaner.