summaryrefslogtreecommitdiff
path: root/python/binaryview.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/binaryview.py')
-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: