diff options
author | Anna Zaks <ganna@apple.com> | 2012-06-22 22:42:30 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2012-06-22 22:42:30 +0000 |
commit | 7186dc63094d3ba24e57e16a66a226d21448dd4f (patch) | |
tree | a68ecd9d7eb320cf45ba569e326f406a2448fdfd /lib/StaticAnalyzer | |
parent | 0206425d9f13486bc18ad4fbd84c4a76d2535dc4 (diff) |
[analyzer] Teach malloc checker that initWith[Bytes|Characters}NoCopy
relinquish memory.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159043 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer')
-rw-r--r-- | lib/StaticAnalyzer/Checkers/MallocChecker.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/lib/StaticAnalyzer/Checkers/MallocChecker.cpp index b0fcb25079..50d4273e48 100644 --- a/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -504,7 +504,9 @@ void MallocChecker::checkPreObjCMessage(const ObjCMessage &Msg, // Ex: [NSData dataWithBytesNoCopy:bytes length:10]; // Unless 'freeWhenDone' param set to 0. // TODO: Check that the memory was allocated with malloc. - if (S.getNameForSlot(0) == "dataWithBytesNoCopy" && + if ((S.getNameForSlot(0) == "dataWithBytesNoCopy" || + S.getNameForSlot(0) == "initWithBytesNoCopy" || + S.getNameForSlot(0) == "initWithCharactersNoCopy") && !isFreeWhenDoneSetToZero(Call, S)){ unsigned int argIdx = 0; C.addTransition(FreeMemAux(C, Call.getArg(argIdx), |