1 // https://clang-analyzer.llvm.org/available_checks.html
3 #include "structures.h"
7 int *p
= (int*) malloc(1);
9 free(p
); // warning: attempt to free released memory
12 void test_use_after_free()
14 int *p
= (int*) malloc(sizeof(int));
16 *p
= 1; // warning: use after free
21 int *p
= (int*) malloc(1);
23 return; // warning: memory is never released
26 void test_free_local()
29 free(a
); // warning: argument is not allocated by malloc
32 void test_free_offset()
34 int *p
= (int*) malloc(sizeof(char));
36 free(p
); // warning: argument to free() is offset by -4 bytes