diff options
author | Anna Zaks <ganna@apple.com> | 2012-01-30 06:42:48 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2012-01-30 06:42:48 +0000 |
commit | af5f550de34525b27f0ff31dafce792caf8158b6 (patch) | |
tree | a284c9b424dc215da28e6e792c15ff53d3d8da6e /lib/StaticAnalyzer/Core/ProgramState.cpp | |
parent | e727d21d3fd5f6f68d9e7a260bbf84dc2fc8ae3a (diff) |
[analyzer] Add index out of bounds check for CFArrayGetArrayAtIndex.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149228 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/ProgramState.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Core/ProgramState.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/StaticAnalyzer/Core/ProgramState.cpp b/lib/StaticAnalyzer/Core/ProgramState.cpp index 8c48a44073..b8b9ad94df 100644 --- a/lib/StaticAnalyzer/Core/ProgramState.cpp +++ b/lib/StaticAnalyzer/Core/ProgramState.cpp @@ -274,7 +274,8 @@ ProgramState::bindExprAndLocation(const Stmt *S, const LocationContext *LCtx, ProgramStateRef ProgramState::assumeInBound(DefinedOrUnknownSVal Idx, DefinedOrUnknownSVal UpperBound, - bool Assumption) const { + bool Assumption, + QualType indexTy) const { if (Idx.isUnknown() || UpperBound.isUnknown()) return this; @@ -288,7 +289,8 @@ ProgramStateRef ProgramState::assumeInBound(DefinedOrUnknownSVal Idx, // Get the offset: the minimum value of the array index type. BasicValueFactory &BVF = svalBuilder.getBasicValueFactory(); // FIXME: This should be using ValueManager::ArrayindexTy...somehow. - QualType indexTy = Ctx.IntTy; + if (indexTy.isNull()) + indexTy = Ctx.IntTy; nonloc::ConcreteInt Min(BVF.getMinValue(indexTy)); // Adjust the index. |