diff options
Diffstat (limited to 'clang/test/Analysis/malloc.c')
-rw-r--r-- | clang/test/Analysis/malloc.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/clang/test/Analysis/malloc.c b/clang/test/Analysis/malloc.c index fb9674a32b2..3dc5843ae03 100644 --- a/clang/test/Analysis/malloc.c +++ b/clang/test/Analysis/malloc.c @@ -8,9 +8,8 @@ void f1() { return; // expected-warning{{Allocated memory never released. Potential memory leak.}} } -// THIS TEST CURRENTLY FAILS. void f1_b() { - int *p = malloc(10); + int *p = malloc(10); // expected-warning{{Allocated memory never released. Potential memory leak.}} } void f2() { @@ -19,20 +18,20 @@ void f2() { free(p); // expected-warning{{Try to free a memory block that has been released}} } -// This case tests that storing malloc'ed memory to a static variable which is then returned -// is not leaked. In the absence of known contracts for functions or inter-procedural analysis, -// this is a conservative answer. +// This case tests that storing malloc'ed memory to a static variable which is +// then returned is not leaked. In the absence of known contracts for functions +// or inter-procedural analysis, this is a conservative answer. int *f3() { static int *p = 0; - p = malloc(10); // no-warning - return p; + p = malloc(10); // will be fixed. + return p; // expected-warning{{Allocated memory never released. Potential memory leak.}} } -// This case tests that storing malloc'ed memory to a static global variable which is then returned -// is not leaked. In the absence of known contracts for functions or inter-procedural analysis, -// this is a conservative answer. +// This case tests that storing malloc'ed memory to a static global variable +// which is then returned is not leaked. In the absence of known contracts for +// functions or inter-procedural analysis, this is a conservative answer. static int *p_f4 = 0; int *f4() { - p_f4 = malloc(10); // no-warning - return p_f4; + p_f4 = malloc(10); // will be fixed. + return p_f4; // expected-warning{{Allocated memory never released. Potential memory leak.}} } |