From: Anna Zaks Date: Wed, 15 Feb 2012 00:11:28 +0000 (+0000) Subject: [analyzer] Malloc Checker: Add another false positive as a todo test. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ebc1d3261e42f45d693fffef5a01a570ef2e89cf;p=clang [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 2d62706ce4..ec9c19de88 100644 --- a/test/Analysis/malloc.c +++ b/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}} +} +