diff options
author | Anna Zaks <ganna@apple.com> | 2012-02-15 00:11:28 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2012-02-15 00:11:28 +0000 |
commit | 5a6213d22b8bc4fdd7092693632c86e2a78e39ce (patch) | |
tree | 557ca9cdb805e1b15010bf7444c412c38969e32e | |
parent | ac06814d2f46cb12491b25911e25bb294c65adbf (diff) | |
download | bcm5719-llvm-5a6213d22b8bc4fdd7092693632c86e2a78e39ce.tar.gz bcm5719-llvm-5a6213d22b8bc4fdd7092693632c86e2a78e39ce.zip |
[analyzer] Malloc Checker: Add another false positive as a todo test.
llvm-svn: 150534
-rw-r--r-- | clang/test/Analysis/malloc.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/test/Analysis/malloc.c b/clang/test/Analysis/malloc.c index 2d62706ce44..ec9c19de880 100644 --- a/clang/test/Analysis/malloc.c +++ b/clang/test/Analysis/malloc.c @@ -11,6 +11,7 @@ void *calloc(size_t nmemb, size_t size); void myfoo(int *p); void myfooint(int p); +char *fooRetPtr(); void f1() { int *p = malloc(12); @@ -441,6 +442,11 @@ void mallocFailedOrNotLeak() { 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 @@ static void *specialMalloc(int n){ } 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}} +} + |