[cfe-commits] r150534 - /cfe/trunk/test/Analysis/malloc.c

Anna Zaks ganna at apple.com
Tue Feb 14 16:11:28 PST 2012


Author: zaks
Date: Tue Feb 14 18:11:28 2012
New Revision: 150534

URL: http://llvm.org/viewvc/llvm-project?rev=150534&view=rev
Log:
[analyzer] Malloc Checker: Add another false positive as a todo test.

Modified:
    cfe/trunk/test/Analysis/malloc.c

Modified: cfe/trunk/test/Analysis/malloc.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/malloc.c?rev=150534&r1=150533&r2=150534&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/malloc.c (original)
+++ cfe/trunk/test/Analysis/malloc.c Tue Feb 14 18:11:28 2012
@@ -11,6 +11,7 @@
 
 void myfoo(int *p);
 void myfooint(int p);
+char *fooRetPtr();
 
 void f1() {
   int *p = malloc(12);
@@ -441,6 +442,11 @@
     return; // expected-warning {{Allocated memory never released. Potential memory leak.}}
 }
 
+void mallocAssignment() {
+  char *p = malloc(12);
+  p = fooRetPtr(); // expected-warning {{leak}}
+}
+
 int vallocTest() {
   char *mem = valloc(12);
   return 0; // expected-warning {{Allocated memory never released. Potential memory leak.}}
@@ -586,3 +592,11 @@
   }
   return p;// expected-warning {{Allocated memory never released. Potential memory leak.}}
 }
+
+// TODO: This is a false positve that should be fixed by making CString checker smarter.
+void symbolLostWithStrcpy(char *s) {
+  char *p = malloc(12);
+  p = strcpy(p, s);
+  free(p);// expected-warning {{leak}}
+}
+





More information about the cfe-commits mailing list