| File: | test.c |
| Location: | line 19, column 5 |
| Description: | Use of memory after it is freed |
| 1 | /* Clang analyser use after free false positive test created by Barry Davis, | |||
| 2 | Stormagic. */ | |||
| 3 | #include <stdlib.h> | |||
| 4 | ||||
| 5 | struct list | |||
| 6 | { | |||
| 7 | void *thing; | |||
| 8 | struct list *next; | |||
| 9 | }; | |||
| 10 | ||||
| 11 | struct list * | |||
| 12 | fool_clang(struct list *item) | |||
| 13 | { | |||
| 14 | struct list *next = item->next; | |||
| 15 | if (next) | |||
| ||||
| 16 | { | |||
| 17 | *item = *next; | |||
| 18 | free(next); | |||
| 19 | return item->next; | |||
| ||||
| 20 | } | |||
| 21 | ||||
| 22 | return item; | |||
| 23 | } |