summaryrefslogtreecommitdiff
path: root/type.cpp
diff options
context:
space:
mode:
authorRyan Snyder <ryan@vector35.com>2018-03-28 13:18:38 -0400
committerRyan Snyder <ryan@vector35.com>2018-03-28 13:18:38 -0400
commitc4e2ab35793daf5d138965eb4d530443f4b54d49 (patch)
treea4ca3b91bcdfceaf3625372b3f50a4cdd8f8e7fa /type.cpp
parent5e56265478e39ec4a1e7bad40c4f8728c5a46214 (diff)
Prevent creation of invalid Type wrappers
Diffstat (limited to 'type.cpp')
-rw-r--r--type.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/type.cpp b/type.cpp
index 0a91ae92..85961a3e 100644
--- a/type.cpp
+++ b/type.cpp
@@ -582,19 +582,19 @@ Ref<Type> Type::NamedType(const QualifiedName& name, Type* type)
Ref<Type> 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> 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;
}