From 8b6eb7ce4f6a7124babd4d7f6f4bb4bb5f6daddf Mon Sep 17 00:00:00 2001 From: Anna Zaks Date: Mon, 29 Aug 2011 20:43:37 +0000 Subject: [PATCH] Fix: Bug 10798 - [analyzer] Crash when analyzing ICU. (A slight improvement on the previous commit.) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138762 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../Checkers/MacOSKeychainAPIChecker.cpp | 2 +- test/Analysis/keychainAPI.m | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp b/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp index 1c9390217f..76d92874be 100644 --- a/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp @@ -203,7 +203,7 @@ static SymbolRef getSymbolForRegion(CheckerContext &C, // region, if that is the case, get the underlining region. if (const ElementRegion *ER = dyn_cast(R)) { R = ER->getAsArrayOffset().getRegion(); - if (!isa(R)) + if (!R || !isa(R)) return 0; } else return 0; diff --git a/test/Analysis/keychainAPI.m b/test/Analysis/keychainAPI.m index 1969a9d169..d10600dea5 100644 --- a/test/Analysis/keychainAPI.m +++ b/test/Analysis/keychainAPI.m @@ -310,3 +310,14 @@ __inline__ static const char *__WBASLLevelString(int level) { return "foo"; } + +static int *bug10798(int *p, int columns, int prevRow) { + int *row = 0; + row = p + prevRow * columns; + prevRow += 2; + do { + ++prevRow; + row+=columns; + } while(10 >= row[1]); + return row; +}