Skip to content

Commit 13c87ea

Browse files
committed
Fix demangler no-type result handling
1 parent c553290 commit 13c87ea

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

demangle.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@ namespace BinaryNinja {
77
bool DemangleGeneric(Ref<Architecture> arch, const std::string& name, Ref<Type>& outType,
88
QualifiedName& outVarName, Ref<BinaryView> view, bool simplify)
99
{
10-
BNType* apiType;
10+
BNType* apiType = nullptr;
1111
BNQualifiedName apiVarName;
1212
bool success = BNDemangleGeneric(
1313
arch->m_object, name.c_str(), &apiType, &apiVarName, view ? view->m_object : nullptr, simplify);
1414

1515
if (!success)
1616
return false;
1717

18-
if (apiType)
19-
outType = new Type(apiType);
18+
outType = apiType ? new Type(apiType) : nullptr;
2019
outVarName = QualifiedName::FromAPIObject(&apiVarName);
2120
BNFreeQualifiedName(&apiVarName);
2221
return true;
@@ -89,7 +88,7 @@ namespace BinaryNinja {
8988
bool DemangleGNU3(Ref<Architecture> arch, const std::string& mangledName, Ref<Type>& outType, QualifiedName& outVarName,
9089
const bool simplify)
9190
{
92-
BNType* localType;
91+
BNType* localType = nullptr;
9392
char** localVarName = nullptr;
9493
size_t localSize = 0;
9594
if (!BNDemangleGNU3(arch->GetObject(), mangledName.c_str(), &localType, &localVarName, &localSize, simplify))
@@ -242,16 +241,15 @@ namespace BinaryNinja {
242241
bool CoreDemangler::Demangle(Ref<Architecture> arch, const std::string& name, Ref<Type>& outType,
243242
QualifiedName& outVarName, Ref<BinaryView> view)
244243
{
245-
BNType* apiType;
244+
BNType* apiType = nullptr;
246245
BNQualifiedName apiVarName;
247246
bool success = BNDemanglerDemangle(
248247
m_object, arch->m_object, name.c_str(), &apiType, &apiVarName, view ? view->m_object : nullptr);
249248

250249
if (!success)
251250
return false;
252251

253-
if (apiType)
254-
outType = new Type(apiType);
252+
outType = apiType ? new Type(apiType) : nullptr;
255253
outVarName = QualifiedName::FromAPIObject(&apiVarName);
256254
BNFreeQualifiedName(&apiVarName);
257255
return true;

0 commit comments

Comments
 (0)