From 5ce116e4d1d3c30537f3635c06d7a0c619e55e43 Mon Sep 17 00:00:00 2001 From: Peter LaFosse Date: Tue, 1 Feb 2022 11:35:10 -0500 Subject: Add support for structured logging --- python/function.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'python/function.py') diff --git a/python/function.py b/python/function.py index 2bd64f4a..b1887628 100644 --- a/python/function.py +++ b/python/function.py @@ -336,8 +336,9 @@ class Function: >>> current_function = bv.functions[0] >>> here = current_function.start """ - def __init__(self, view: Optional['binaryview.BinaryView'] = None, handle: Optional[core.BNFunctionHandle] = None): + def __init__(self, view: Optional['binaryview.BinaryView'] = None, handle:core.BNFunctionHandle=None): self._advanced_analysis_requests = 0 + self.handle = None assert handle is not None, "creation of standalone 'Function' objects is not implemented" FunctionHandle = ctypes.POINTER(core.BNFunction) self.handle = ctypes.cast(handle, FunctionHandle) @@ -349,7 +350,7 @@ class Function: self._platform = None def __del__(self): - if core is not None: + if core is not None and self.handle is not None: if self._advanced_analysis_requests > 0: core.BNReleaseAdvancedFunctionAnalysisDataMultiple(self.handle, self._advanced_analysis_requests) core.BNFreeFunction(self.handle) -- cgit v1.3.1