summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2013-06-19 08:19:56 +0000
committerPavel Labath <labath@google.com>2013-06-19 08:19:56 +0000
commit963f91b3a2b2b3b3a2f34e41333d19e3d79f1017 (patch)
treee54e868024c6a595fd8d415e66fa5137724e6ee6 /clang/lib/StaticAnalyzer/Core/CallEvent.cpp
parenta7cc1243cc6cbeef725ef6883d49c29630c52511 (diff)
downloadbcm5719-llvm-963f91b3a2b2b3b3a2f34e41333d19e3d79f1017.tar.gz
bcm5719-llvm-963f91b3a2b2b3b3a2f34e41333d19e3d79f1017.zip
Fix a crash in the static analyzer (bug #16307)
Summary: When processing a call to a function, which got passed less arguments than it expects, the analyzer would crash. I've also added a test for that and a analyzer warning which detects these cases. CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D994 llvm-svn: 184288
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/CallEvent.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Core/CallEvent.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
index dd33e014c30..9ab68747561 100644
--- a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -272,8 +272,11 @@ static void addParameterValuesToBindings(const StackFrameContext *CalleeCtx,
CallEvent::param_iterator E) {
MemRegionManager &MRMgr = SVB.getRegionManager();
+ // If the function has fewer parameters than the call has arguments, we simply
+ // do not bind any values to them.
+ unsigned NumArgs = Call.getNumArgs();
unsigned Idx = 0;
- for (; I != E; ++I, ++Idx) {
+ for (; I != E && Idx < NumArgs; ++I, ++Idx) {
const ParmVarDecl *ParamDecl = *I;
assert(ParamDecl && "Formal parameter has no decl?");
OpenPOWER on IntegriCloud