summaryrefslogtreecommitdiff
path: root/function.cpp
diff options
context:
space:
mode:
authorGalen Williamson <galen@vector35.com>2022-05-02 13:27:58 -0400
committerGalen Williamson <galen@vector35.com>2022-05-02 13:27:58 -0400
commit8ed00c24795872a33eeb2fd3b00911ef0b45b269 (patch)
treefb631270710026bc68bab48dc9eb664f0800057d /function.cpp
parent41f50feedb0ed33555c4340d1548756d0fed3c3b (diff)
Added nullptr checks in `Function::Get*LevelIL` methods. Fixes #3107.
The `Function::Get*LevelIL` should now be treated like their non-blocking `IfAvailable` variants, in that even if they block, they may still still return null.
Diffstat (limited to 'function.cpp')
-rw-r--r--function.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/function.cpp b/function.cpp
index eb9907af..bacfbab0 100644
--- a/function.cpp
+++ b/function.cpp
@@ -331,7 +331,10 @@ void Function::RemoveUserTypeFieldReference(
Ref<LowLevelILFunction> Function::GetLowLevelIL() const
{
- return new LowLevelILFunction(BNGetFunctionLowLevelIL(m_object));
+ BNLowLevelILFunction* function = BNGetFunctionLowLevelIL(m_object);
+ if (!function)
+ return nullptr;
+ return new LowLevelILFunction(function);
}
@@ -626,7 +629,10 @@ vector<BNConstantReference> Function::GetConstantsReferencedByInstructionIfAvail
Ref<LowLevelILFunction> Function::GetLiftedIL() const
{
- return new LowLevelILFunction(BNGetFunctionLiftedIL(m_object));
+ BNLowLevelILFunction* function = BNGetFunctionLiftedIL(m_object);
+ if (!function)
+ return nullptr;
+ return new LowLevelILFunction(function);
}
@@ -709,13 +715,19 @@ set<uint32_t> Function::GetFlagsWrittenByLiftedILInstruction(size_t i)
Ref<MediumLevelILFunction> Function::GetMediumLevelIL() const
{
- return new MediumLevelILFunction(BNGetFunctionMediumLevelIL(m_object));
+ BNMediumLevelILFunction* function = BNGetFunctionMediumLevelIL(m_object);
+ if (!function)
+ return nullptr;
+ return new MediumLevelILFunction(function);
}
Ref<MediumLevelILFunction> Function::GetMappedMediumLevelIL() const
{
- return new MediumLevelILFunction(BNGetFunctionMappedMediumLevelIL(m_object));
+ BNMediumLevelILFunction* function = BNGetFunctionMappedMediumLevelIL(m_object);
+ if (!function)
+ return nullptr;
+ return new MediumLevelILFunction(function);
}
@@ -739,7 +751,10 @@ Ref<MediumLevelILFunction> Function::GetMappedMediumLevelILIfAvailable() const
Ref<HighLevelILFunction> Function::GetHighLevelIL() const
{
- return new HighLevelILFunction(BNGetFunctionHighLevelIL(m_object));
+ BNHighLevelILFunction* function = BNGetFunctionHighLevelIL(m_object);
+ if (!function)
+ return nullptr;
+ return new HighLevelILFunction(function);
}