From c4e2ab35793daf5d138965eb4d530443f4b54d49 Mon Sep 17 00:00:00 2001 From: Ryan Snyder Date: Wed, 28 Mar 2018 13:18:38 -0400 Subject: Prevent creation of invalid Type wrappers --- type.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'type.cpp') diff --git a/type.cpp b/type.cpp index 0a91ae92..85961a3e 100644 --- a/type.cpp +++ b/type.cpp @@ -582,19 +582,19 @@ Ref Type::NamedType(const QualifiedName& name, Type* type) Ref Type::NamedType(const string& id, const QualifiedName& name, Type* type) { BNQualifiedName nameObj = name.GetAPIObject(); - Type* result = new Type(BNCreateNamedTypeReferenceFromTypeAndId(id.c_str(), &nameObj, - type ? type->GetObject() : nullptr)); + BNType* coreObj = BNCreateNamedTypeReferenceFromTypeAndId(id.c_str(), &nameObj, + type ? type->GetObject() : nullptr); QualifiedName::FreeAPIObject(&nameObj); - return result; + return coreObj ? new Type(coreObj) : nullptr; } Ref Type::NamedType(BinaryView* view, const QualifiedName& name) { BNQualifiedName nameObj = name.GetAPIObject(); - Type* result = new Type(BNCreateNamedTypeReferenceFromType(view->GetObject(), &nameObj)); + BNType* coreObj = BNCreateNamedTypeReferenceFromType(view->GetObject(), &nameObj); QualifiedName::FreeAPIObject(&nameObj); - return result; + return coreObj ? new Type(coreObj) : nullptr; } -- cgit v1.3.1