Revert "[lldb][test] Remove compiler version check and use regex" (#124101)
[llvm-project.git] / clang / docs / analyzer / checkers / unix_malloc_example.c
blob68c5a4a8f1c5fdc158d5f52946cd32923daf0ea6
2 void test() {
3 int *p = malloc(1);
4 free(p);
5 free(p); // warn: attempt to free released memory
8 void test() {
9 int *p = malloc(sizeof(int));
10 free(p);
11 *p = 1; // warn: use after free
14 void test() {
15 int *p = malloc(1);
16 if (p)
17 return; // warn: memory is never released
20 void test() {
21 int a[] = { 1 };
22 free(a); // warn: argument is not allocated by malloc
25 void test() {
26 int *p = malloc(sizeof(char));
27 p = p - 1;
28 free(p); // warn: argument to free() is offset by -4 bytes