From 9e06c61f699423ef20673e963207fed4dd02bf42 Mon Sep 17 00:00:00 2001 From: Peter LaFosse Date: Thu, 3 Aug 2023 09:40:39 -0400 Subject: Ensure Type objects are created correctly everywhere and add guardrail --- python/types.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'python/types.py') diff --git a/python/types.py b/python/types.py index f4df25f1..570f9ce1 100644 --- a/python/types.py +++ b/python/types.py @@ -1411,7 +1411,7 @@ class StructureBuilder(TypeBuilder): return None try: return StructureMember( - Type(core.BNNewTypeReference(member.contents.type), confidence=member.contents.typeConfidence), + Type.create(core.BNNewTypeReference(member.contents.type), confidence=member.contents.typeConfidence), member.contents.name, member.contents.offset, MemberAccess(member.contents.access), MemberScope(member.contents.scope) ) @@ -1754,6 +1754,8 @@ class Type: """ def __init__(self, handle, platform: Optional['_platform.Platform'] = None, confidence: int = core.max_confidence): assert isinstance(handle.contents, core.BNType), "Attempting to create mutable Type" + if self.__class__ == Type: + raise Exception("Cannot instantiate Type directly use Type.create instead") self._handle = handle self._confidence = confidence self._platform = platform -- cgit v1.3.1