r338775 - [analyzer] Add a safety check to InnerPointerChecker.
Reka Kovacs via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 2 15:19:57 PDT 2018
Author: rkovacs
Date: Thu Aug 2 15:19:57 2018
New Revision: 338775
URL: http://llvm.org/viewvc/llvm-project?rev=338775&view=rev
Log:
[analyzer] Add a safety check to InnerPointerChecker.
Do not crash if the CXXRecordDecl of an object is not available.
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp?rev=338775&r1=338774&r2=338775&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp Thu Aug 2 15:19:57 2018
@@ -129,8 +129,11 @@ bool InnerPointerChecker::isCalledOnStri
return false;
QualType ObjTy = ObjRegion->getValueType();
- if (ObjTy.isNull() ||
- ObjTy->getAsCXXRecordDecl()->getName() != "basic_string")
+ if (ObjTy.isNull())
+ return false;
+
+ CXXRecordDecl *Decl = ObjTy->getAsCXXRecordDecl();
+ if (!Decl || Decl->getName() != "basic_string")
return false;
return true;
More information about the cfe-commits
mailing list