diff options
| author | Ryan Snyder <ryan@vector35.com> | 2018-09-26 07:11:37 -0400 |
|---|---|---|
| committer | Ryan Snyder <ryan@vector35.com> | 2018-09-26 11:21:29 -0400 |
| commit | bd0215667a465dc23b4d0949fd8457d7e6411fd7 (patch) | |
| tree | 881fe9a1d294d64b8b2487ad60c64514490b7e44 /python/downloadprovider.py | |
| parent | 474af687134930f8c1e8f13c6cfe5fd5574cf8c3 (diff) | |
python3: ensure callbacks live long enough
Diffstat (limited to 'python/downloadprovider.py')
| -rw-r--r-- | python/downloadprovider.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/python/downloadprovider.py b/python/downloadprovider.py index eb9735f3..10f9dee1 100644 --- a/python/downloadprovider.py +++ b/python/downloadprovider.py @@ -39,6 +39,7 @@ from binaryninja import range class DownloadInstance(object): + _registered_instances = [] def __init__(self, provider, handle = None): if handle is None: self._cb = core.BNDownloadInstanceCallbacks() @@ -46,15 +47,18 @@ class DownloadInstance(object): self._cb.destroyInstance = self._cb.destroyInstance.__class__(self._destroy_instance) self._cb.performRequest = self._cb.performRequest.__class__(self._perform_request) self.handle = core.BNInitDownloadInstance(provider.handle, self._cb) + self.__class__._registered_instances.append(self) else: self.handle = core.handle_of_type(handle, core.BNDownloadInstance) - self._outputCallbacks = None + self._must_free = handle is not None def __del__(self): - core.BNFreeDownloadInstance(self.handle) + if self._must_free: + core.BNFreeDownloadInstance(self.handle) def _destroy_instance(self, ctxt): try: + self.__class__._registered_instances.remove(self) self.perform_destroy_instance() except: log.log_error(traceback.format_exc()) |
