diff options
Diffstat (limited to 'clang/test/Analysis/malloc.c')
-rw-r--r-- | clang/test/Analysis/malloc.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/clang/test/Analysis/malloc.c b/clang/test/Analysis/malloc.c index cbc21b492e5..5288e21a282 100644 --- a/clang/test/Analysis/malloc.c +++ b/clang/test/Analysis/malloc.c @@ -1758,8 +1758,8 @@ void constEscape(const void *ptr); void testConstEscapeThroughAnotherField() { struct IntAndPtr s; s.p = malloc(sizeof(int)); - constEscape(&(s.x)); -} // expected-warning {{Potential leak of memory pointed to by 's.p'}} + constEscape(&(s.x)); // could free s->p! +} // no-warning // PR15623 int testNoCheckerDataPropogationFromLogicalOpOperandToOpResult(void) { @@ -1812,6 +1812,22 @@ void testLivenessBug(struct B *in_b) { livenessBugRealloc(b->a); } +struct ListInfo { + struct ListInfo *next; +}; + +struct ConcreteListItem { + struct ListInfo li; + int i; +}; + +void list_add(struct ListInfo *list, struct ListInfo *item); + +void testCStyleListItems(struct ListInfo *list) { + struct ConcreteListItem *x = malloc(sizeof(struct ConcreteListItem)); + list_add(list, &x->li); // will free 'x'. +} + // ---------------------------------------------------------------------------- // False negatives. |