summaryrefslogtreecommitdiff
path: root/python/downloadprovider.py
diff options
context:
space:
mode:
authorRyan Snyder <ryan@vector35.com>2018-09-26 07:11:37 -0400
committerPeter LaFosse <peter@vector35.com>2018-10-05 14:46:17 -0400
commitd6493e39ab0d85565245139fd66265fc30e6b0cf (patch)
treeb79abee99c75c3ca12e56cf328a41e86e325e4a8 /python/downloadprovider.py
parent39e136f42c1e19a366667d3d23b38065902f4599 (diff)
python3: ensure callbacks live long enough
Diffstat (limited to 'python/downloadprovider.py')
-rw-r--r--python/downloadprovider.py8
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())