From 5646f03f9a61feb24584a8a5da94027783b16e5a Mon Sep 17 00:00:00 2001 From: Peter LaFosse Date: Fri, 18 Mar 2022 12:35:46 -0400 Subject: Fix a bunch of reference miscounts in the C++ and python apis --- python/binaryview.py | 8 ++++---- python/typelibrary.py | 4 ++-- python/types.py | 8 ++++++-- 3 files changed, 12 insertions(+), 8 deletions(-) (limited to 'python') diff --git a/python/binaryview.py b/python/binaryview.py index 3ebe79af..84a415e2 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -6293,7 +6293,7 @@ class BinaryView: obj = core.BNGetAnalysisTypeByName(self.handle, _name) if not obj: return None - return _types.Type.create(obj, platform=self.platform) + return _types.Type.create(core.BNNewTypeReference(obj), platform=self.platform) def get_type_by_id(self, id: str) -> Optional['_types.Type']: """ @@ -6314,7 +6314,7 @@ class BinaryView: obj = core.BNGetAnalysisTypeById(self.handle, id) if not obj: return None - return _types.Type.create(obj, platform=self.platform) + return _types.Type.create(core.BNNewTypeReference(obj), platform=self.platform) def get_type_name_by_id(self, id: str) -> Optional['_types.QualifiedName']: """ @@ -6550,7 +6550,7 @@ class BinaryView: ) if handle is None: return None - return _types.Type.create(handle, platform=self.platform) + return _types.Type.create(core.BNNewTypeReference(handle), platform=self.platform) def import_library_object(self, name: str, lib: typelibrary.TypeLibrary = None) -> Optional['_types.Type']: """ @@ -6572,7 +6572,7 @@ class BinaryView: ) if handle is None: return None - return _types.Type.create(handle, platform=self.platform) + return _types.Type.create(core.BNNewTypeReference(handle), platform=self.platform) def export_type_to_library(self, lib: typelibrary.TypeLibrary, name: Optional[str], type_obj: StringOrType) -> None: """ diff --git a/python/typelibrary.py b/python/typelibrary.py index 8a56e978..2d2c8fb1 100644 --- a/python/typelibrary.py +++ b/python/typelibrary.py @@ -321,7 +321,7 @@ class TypeLibrary: t = core.BNGetTypeLibraryNamedObject(self.handle, name._to_core_struct()) if t is None: return None - return types.Type.create(t) + return types.Type.create(core.BNNewTypeReference(t)) def get_named_type(self, name: str) -> Optional[types.Type]: """ @@ -337,7 +337,7 @@ class TypeLibrary: t = core.BNGetTypeLibraryNamedType(self.handle, name._to_core_struct()) if t is None: return None - return types.Type.create(t) + return types.Type.create(core.BNNewTypeReference(t)) @property def named_objects(self) -> Dict[str, types.Type]: diff --git a/python/types.py b/python/types.py index 2201e6a6..69ab0a8d 100644 --- a/python/types.py +++ b/python/types.py @@ -1799,10 +1799,14 @@ class Type: return MutableTypeBuilder(type.mutable_copy(), bv, name, platform, confidence) def with_replaced_structure(self, from_struct, to_struct): - return Type.create(handle=core.BNTypeWithReplacedStructure(self._handle, from_struct.handle, to_struct.handle)) + handle = core.BNTypeWithReplacedStructure(self._handle, from_struct.handle, to_struct.handle) + ref_handle = core.BNNewTypeReference(handle) + return Type.create(handle=ref_handle) def with_replaced_enumeration(self, from_enum, to_enum): - return Type.create(handle=core.BNTypeWithReplacedEnumeration(self._handle, from_enum.handle, to_enum.handle)) + handle = core.BNTypeWithReplacedEnumeration(self._handle, from_enum.handle, to_enum.handle) + ref_handle = core.BNNewTypeReference(handle) + return Type.create(handle=ref_handle) def with_replaced_named_type_reference(self, from_ref, to_ref): return Type.create( -- cgit v1.3.1