summaryrefslogtreecommitdiff
path: root/python/flowgraph.py
diff options
context:
space:
mode:
authorRusty Wagner <rusty@vector35.com>2019-05-10 16:15:48 -0400
committerRusty Wagner <rusty@vector35.com>2019-05-10 16:15:48 -0400
commitf6659517c08799cf52fddd09424eaea867ff3ed7 (patch)
treeab06cf065b7c152dff91658c7247946cb7ffaec8 /python/flowgraph.py
parent63a4020845a81cf8793ddb02c7d5c95e3317d2a1 (diff)
Fix memory leak and use after free bugs in BinaryView and FlowGraph objects
Diffstat (limited to 'python/flowgraph.py')
-rw-r--r--python/flowgraph.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/python/flowgraph.py b/python/flowgraph.py
index 58add8b0..189b075c 100644
--- a/python/flowgraph.py
+++ b/python/flowgraph.py
@@ -338,6 +338,8 @@ class FlowGraph(object):
from incoming edges, or graphs that have disjoint subgraphs will not render correctly. This will be fixed \
in a future version.
"""
+ _registered_instances = []
+
def __init__(self, handle = None):
if handle is None:
self._ext_cb = core.BNCustomFlowGraph()
@@ -346,6 +348,8 @@ class FlowGraph(object):
self._ext_cb.populateNodes = self._ext_cb.populateNodes.__class__(self._populate_nodes)
self._ext_cb.completeLayout = self._ext_cb.completeLayout.__class__(self._complete_layout)
self._ext_cb.update = self._ext_cb.update.__class__(self._update)
+ self._ext_cb.externalRefTaken = self._ext_cb.externalRefTaken.__class__(self._external_ref_taken)
+ self._ext_cb.externalRefReleased = self._ext_cb.externalRefReleased.__class__(self._external_ref_released)
handle = core.BNCreateCustomFlowGraph(self._ext_cb)
self.handle = handle
@@ -390,6 +394,18 @@ class FlowGraph(object):
log.log_error(traceback.format_exc())
return None
+ def _external_ref_taken(self, ctxt):
+ try:
+ self.__class__._registered_instances.append(self)
+ except:
+ log.log_error(traceback.format_exc())
+
+ def _external_ref_released(self, ctxt):
+ try:
+ self.__class__._registered_instances.remove(self)
+ except:
+ log.log_error(traceback.format_exc())
+
def finish_prepare_for_layout(self):
"""
``finish_prepare_for_layout`` signals that preparations for rendering a graph are complete.