Skip to content

Commit 0570a89

Browse files
committed
Fix Type object leaks in the Python type API
1 parent db6d95e commit 0570a89

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

python/types.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,8 +790,6 @@ def __len__(self):
790790
def finalized(self):
791791
type_handle = core.BNFinalizeTypeBuilder(self._handle)
792792
assert type_handle is not None, "core.BNFinalizeTypeBuilder returned None"
793-
type_handle = core.BNNewTypeReference(type_handle)
794-
assert type_handle is not None, "core.BNNewTypeReference returned None"
795793
return type_handle
796794

797795
@property
@@ -2586,6 +2584,7 @@ def from_core_struct(cls, structure: core.BNStructure) -> 'StructureType':
25862584
def __del__(self):
25872585
if core is not None:
25882586
core.BNFreeStructure(self.struct_handle)
2587+
super(StructureType, self).__del__()
25892588

25902589
def __hash__(self):
25912590
return hash(ctypes.addressof(self.struct_handle.contents))
@@ -2833,6 +2832,7 @@ def __init__(self, handle, platform: Optional['_platform.Platform'] = None, conf
28332832
def __del__(self):
28342833
if core is not None:
28352834
core.BNFreeEnumeration(self.enum_handle)
2835+
super(EnumerationType, self).__del__()
28362836

28372837
def __hash__(self):
28382838
return hash(ctypes.addressof(self.enum_handle.contents))
@@ -3293,6 +3293,7 @@ def create_from_registered_type(
32933293
def __del__(self):
32943294
if core is not None:
32953295
core.BNFreeNamedTypeReference(self.ntr_handle)
3296+
super(NamedTypeReferenceType, self).__del__()
32963297

32973298
def __repr__(self):
32983299
if self.named_type_class == NamedTypeReferenceClass.TypedefNamedTypeClass:

0 commit comments

Comments
 (0)