[analyzer] Fix a false positive reported on rare strange code, which happens to be in JSONKit
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183055 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
index 11abe9a..bb2e2df 100644
--- a/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -1890,6 +1890,12 @@
return false;
}
+ // We should escape on call to 'init'. This is especially relevant to the
+ // receiver, as the corresponding symbol is usually not referenced after
+ // the call.
+ if (Msg->getMethodFamily() == OMF_init)
+ return false;
+
// Otherwise, assume that the method does not free memory.
// Most framework methods do not free memory.
return true;