]> granicus.if.org Git - clang/commitdiff
[Analyzer] Check function name size before indexing.
authorGeorge Karpenkov <ekarpenkov@apple.com>
Fri, 15 Sep 2017 19:51:26 +0000 (19:51 +0000)
committerGeorge Karpenkov <ekarpenkov@apple.com>
Fri, 15 Sep 2017 19:51:26 +0000 (19:51 +0000)
https://reviews.llvm.org/D37908

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@313385 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
test/Analysis/retain-release.mm

index c348ecf4fd8bf03ec1dba97ca9a888d67688180e..165bc049938879a85ae3ec87f84127c16f6b2752 100644 (file)
@@ -1211,7 +1211,8 @@ RetainSummaryManager::getFunctionSummary(const FunctionDecl *FD) {
 
     // Check for release functions, the only kind of functions that we care
     // about that don't return a pointer type.
-    if (FName[0] == 'C' && (FName[1] == 'F' || FName[1] == 'G')) {
+    if (FName.size() >= 2 &&
+        FName[0] == 'C' && (FName[1] == 'F' || FName[1] == 'G')) {
       // Test for 'CGCF'.
       FName = FName.substr(FName.startswith("CGCF") ? 4 : 2);
 
index c9817005c2c556e86385aeae6cdb6ab6067333d5..c694fd33c59602644bc053d1625a8f0f2c5e389b 100644 (file)
@@ -461,3 +461,5 @@ void        radar13722286::PrepareBitmap() {
        }
 }
 
+// rdar://34210609
+void _() { _(); }; // no-warning