From 3c4cf9b06f81e6a2f614ce373a72fa68e6e1a4c0 Mon Sep 17 00:00:00 2001 From: Brian Potchik Date: Sat, 2 Sep 2023 01:46:31 -0400 Subject: Fix python BinaryView instance refcounting. --- python/binaryview.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'python') 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: -- cgit v1.3.1