summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
diff options
context:
space:
mode:
authorAlexander Shaposhnikov <shal1t712@gmail.com>2018-01-22 20:18:42 +0000
committerAlexander Shaposhnikov <shal1t712@gmail.com>2018-01-22 20:18:42 +0000
commitd7d991e881fb3f74325a13cc80cc5467eb43af65 (patch)
tree0db0c50f5f83d06da2097479351b1aeeed634f6b /clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
parentae858bf65fef652108ca926b1acf0a636a0fc057 (diff)
downloadbcm5719-llvm-d7d991e881fb3f74325a13cc80cc5467eb43af65.tar.gz
bcm5719-llvm-d7d991e881fb3f74325a13cc80cc5467eb43af65.zip
[analyzer] Protect against dereferencing a null pointer
The check (inside StackHintGeneratorForSymbol::getMessage) if (!N) return getMessageForSymbolNotFound() is moved to the beginning of the function. Differential revision: https://reviews.llvm.org/D42388 Test plan: make check-all llvm-svn: 323146
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp b/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
index b03517c02a8..fd3de613840 100644
--- a/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ b/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -1185,6 +1185,9 @@ void PathDiagnostic::FullProfile(llvm::FoldingSetNodeID &ID) const {
StackHintGenerator::~StackHintGenerator() {}
std::string StackHintGeneratorForSymbol::getMessage(const ExplodedNode *N){
+ if (!N)
+ return getMessageForSymbolNotFound();
+
ProgramPoint P = N->getLocation();
CallExitEnd CExit = P.castAs<CallExitEnd>();
@@ -1194,9 +1197,6 @@ std::string StackHintGeneratorForSymbol::getMessage(const ExplodedNode *N){
if (!CE)
return "";
- if (!N)
- return getMessageForSymbolNotFound();
-
// Check if one of the parameters are set to the interesting symbol.
unsigned ArgIndex = 0;
for (CallExpr::const_arg_iterator I = CE->arg_begin(),
OpenPOWER on IntegriCloud