diff options
Diffstat (limited to 'test/Analysis/malloc.c')
-rw-r--r-- | test/Analysis/malloc.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/Analysis/malloc.c b/test/Analysis/malloc.c index 964424647f..7f5062af45 100644 --- a/test/Analysis/malloc.c +++ b/test/Analysis/malloc.c @@ -1007,3 +1007,15 @@ void freeButNoMalloc(int *p, int x){ } free(p); // expected-warning {{Attempt to free released memory}} } + +struct HasPtr { + int *p; +}; + +int* reallocButNoMalloc(struct HasPtr *a, int c, int size) { + int *s; + a->p = (int *)realloc(a->p, size); + if (a->p == 0) + return 0; // expected-warning{{Memory is never released; potential leak}} + return a->p; +} |