From 8ed00c24795872a33eeb2fd3b00911ef0b45b269 Mon Sep 17 00:00:00 2001 From: Galen Williamson Date: Mon, 2 May 2022 13:27:58 -0400 Subject: 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. --- function.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'function.cpp') 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 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 Function::GetConstantsReferencedByInstructionIfAvail Ref 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 Function::GetFlagsWrittenByLiftedILInstruction(size_t i) Ref Function::GetMediumLevelIL() const { - return new MediumLevelILFunction(BNGetFunctionMediumLevelIL(m_object)); + BNMediumLevelILFunction* function = BNGetFunctionMediumLevelIL(m_object); + if (!function) + return nullptr; + return new MediumLevelILFunction(function); } Ref 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 Function::GetMappedMediumLevelILIfAvailable() const Ref Function::GetHighLevelIL() const { - return new HighLevelILFunction(BNGetFunctionHighLevelIL(m_object)); + BNHighLevelILFunction* function = BNGetFunctionHighLevelIL(m_object); + if (!function) + return nullptr; + return new HighLevelILFunction(function); } -- cgit v1.3.1