From e23cee92136668950031215e56910e0037efc3e2 Mon Sep 17 00:00:00 2001 From: SanthoshMohan Date: Tue, 31 Oct 2023 16:48:45 +0100 Subject: [PATCH 1/3] Null checking getCalledFunction() when calling getName() --- .../IfdsIde/Problems/IDESecureHeapPropagation.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESecureHeapPropagation.cpp b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESecureHeapPropagation.cpp index a068537877..c43656df73 100644 --- a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESecureHeapPropagation.cpp +++ b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESecureHeapPropagation.cpp @@ -87,9 +87,11 @@ IDESecureHeapPropagation::getCallToRetFlowFunction( // Change to CallSite everywhere const auto *CS = llvm::cast(CallSite); - auto FName = CS->getCalledFunction()->getName(); - if (FName == InitializerFn) { - return generateFromZero(SecureHeapFact::INITIALIZED); + if (CS->getCalledFunction()) { + auto FName = CS->getCalledFunction()->getName(); + if (FName == InitializerFn) { + return generateFromZero(SecureHeapFact::INITIALIZED); + } } return identityFlow(); } @@ -147,7 +149,7 @@ IDESecureHeapPropagation::getCallToRetEdgeFunction( return SHPGenEdgeFn{l_t::INITIALIZED}; } const auto *CS = llvm::cast(CallSite); - if (CallNode != ZeroValue && + if (CallNode != ZeroValue && CS->getCalledFunction() && CS->getCalledFunction()->getName() == ShutdownFn) { // std::cerr << "Kill at " << llvmIRToShortString(callSite) << std::endl; return SHPGenEdgeFn{l_t::BOT}; From 19d937d4966d949e953abe0b4b9cda18cc700245 Mon Sep 17 00:00:00 2001 From: Fabian Schiebel <52407375+fabianbs96@users.noreply.github.com> Date: Mon, 6 Nov 2023 14:15:20 +0100 Subject: [PATCH 2/3] minor --- .../DataFlow/IfdsIde/Problems/IDESecureHeapPropagation.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESecureHeapPropagation.cpp b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESecureHeapPropagation.cpp index c43656df73..1ef0b66b90 100644 --- a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESecureHeapPropagation.cpp +++ b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESecureHeapPropagation.cpp @@ -87,9 +87,8 @@ IDESecureHeapPropagation::getCallToRetFlowFunction( // Change to CallSite everywhere const auto *CS = llvm::cast(CallSite); - if (CS->getCalledFunction()) { - auto FName = CS->getCalledFunction()->getName(); - if (FName == InitializerFn) { + if (const auto * Callee = CS->getCalledFunction()) { + if (Callee->getName() == InitializerFn) { return generateFromZero(SecureHeapFact::INITIALIZED); } } From 9e7b2ac899ed08f81776c0c5ef28b2dc69a22f0e Mon Sep 17 00:00:00 2001 From: Fabian Schiebel <52407375+fabianbs96@users.noreply.github.com> Date: Mon, 6 Nov 2023 14:16:04 +0100 Subject: [PATCH 3/3] pre-commit --- .../DataFlow/IfdsIde/Problems/IDESecureHeapPropagation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESecureHeapPropagation.cpp b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESecureHeapPropagation.cpp index 1ef0b66b90..225b701fa5 100644 --- a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESecureHeapPropagation.cpp +++ b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESecureHeapPropagation.cpp @@ -87,7 +87,7 @@ IDESecureHeapPropagation::getCallToRetFlowFunction( // Change to CallSite everywhere const auto *CS = llvm::cast(CallSite); - if (const auto * Callee = CS->getCalledFunction()) { + if (const auto *Callee = CS->getCalledFunction()) { if (Callee->getName() == InitializerFn) { return generateFromZero(SecureHeapFact::INITIALIZED); }