[analyzer] Malloc Checker: Add another false positive as a todo test.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150534 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Analysis/malloc.c b/test/Analysis/malloc.c
index 2d62706..ec9c19d 100644
--- a/test/Analysis/malloc.c
+++ b/test/Analysis/malloc.c
@@ -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}}
+}
+