[analyzer]Fix false positive: pointer might escape through CG*WithData.

llvm-svn: 154156
This commit is contained in:
Anna Zaks 2012-04-06 01:00:47 +00:00
parent f1548d4f74
commit e8628c5bc7
2 changed files with 19 additions and 0 deletions

View File

@ -278,6 +278,7 @@ public:
if (StrInStrNoCase(FName, "InsertValue") != StringRef::npos||
StrInStrNoCase(FName, "AddValue") != StringRef::npos ||
StrInStrNoCase(FName, "SetValue") != StringRef::npos ||
StrInStrNoCase(FName, "WithData") != StringRef::npos ||
StrInStrNoCase(FName, "AppendValue") != StringRef::npos||
StrInStrNoCase(FName, "SetAttribute") != StringRef::npos) {
return true;

View File

@ -136,3 +136,21 @@ static inline void radar11111210(OSQueueHead *pool) {
OSAtomicEnqueue(pool, newItem, 4);
}
// Pointer might escape through CGDataProviderCreateWithData (radar://11187558).
typedef struct CGDataProvider *CGDataProviderRef;
typedef void (*CGDataProviderReleaseDataCallback)(void *info, const void *data,
size_t size);
extern CGDataProviderRef CGDataProviderCreateWithData(void *info,
const void *data, size_t size,
CGDataProviderReleaseDataCallback releaseData)
__attribute__((visibility("default")));
void *calloc(size_t, size_t);
static void releaseDataCallback (void *info, const void *data, size_t size) {
#pragma unused (info, size)
free((void*)data);
}
void testCGDataProviderCreateWithData() {
void* b = calloc(8, 8);
CGDataProviderRef p = CGDataProviderCreateWithData(0, b, 8*8, releaseDataCallback);
}