[analyzer] Fix a false positive reported on rare strange code, which happens to be in JSONKit

llvm-svn: 183055
This commit is contained in:
Anna Zaks 2013-05-31 22:39:13 +00:00
parent 1ec87e8bb0
commit 737926ba6c
2 changed files with 16 additions and 0 deletions

View File

@ -1890,6 +1890,12 @@ bool MallocChecker::doesNotFreeMemOrInteresting(const CallEvent *Call,
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;

View File

@ -35,3 +35,13 @@ void rdar10579586(char x);
}
@end
@interface JKArray : NSObject {
id * objects;
}
@end
void _JKArrayCreate() {
JKArray *array = (JKArray *)malloc(12);
array = [array init];
free(array); // no-warning
}