]> granicus.if.org Git - clang/commitdiff
[analyzer]Fix false positive: pointer might escape through CG*WithData.
authorAnna Zaks <ganna@apple.com>
Fri, 6 Apr 2012 01:00:47 +0000 (01:00 +0000)
committerAnna Zaks <ganna@apple.com>
Fri, 6 Apr 2012 01:00:47 +0000 (01:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154156 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/StaticAnalyzer/Core/PathSensitive/ObjCMessage.h
test/Analysis/malloc.mm

index 33934af10cc611ef5c0c8ba04192119e5866784a..d8aec0991d9a9f5cf93c5156dd7eed96a1d325a6 100644 (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;
index d2409ac1609ce868d0d890a1a0f12fde440ba363..3515a4f99af0000f51427c0dea890ad1e125c97d 100644 (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);
+}
\ No newline at end of file