summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorBrian Potchik <brian@vector35.com>2023-09-02 01:46:31 -0400
committerPeter LaFosse <peter@vector35.com>2023-09-02 08:45:26 -0400
commit3c4cf9b06f81e6a2f614ce373a72fa68e6e1a4c0 (patch)
tree6037f170d11a1a18bf61b55fa1cc5bc202c4f4f7 /python
parent1882088834620730520694805954431773142869 (diff)
Fix python BinaryView instance refcounting.
Diffstat (limited to 'python')
-rw-r--r--python/binaryview.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/python/binaryview.py b/python/binaryview.py
index 7d1f221b..bbc2fb2e 100644
--- a/python/binaryview.py
+++ b/python/binaryview.py
@@ -1933,6 +1933,7 @@ class BinaryView:
if handle:
key = ctypes.addressof(handle.contents)
if key in cls._cached_instances:
+ core.BNFreeBinaryView(handle) # release the already taken reference since we are pulling from the cache
return cls._cached_instances[key]
return super().__new__(cls)
@@ -1941,9 +1942,9 @@ class BinaryView:
handle: Optional[core.BNBinaryViewHandle] = None
):
if handle is not None:
- _handle = handle
if self.__class__._cache_contains(handle):
return
+ _handle = handle
if file_metadata is None:
self._file = filemetadata.FileMetadata(handle=core.BNGetFileForView(handle))
else: