• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cl_asan -O0 %s -Fe%t
2 // RUN: %run %t | FileCheck %s
3 
4 #include <malloc.h>
5 #include <stdio.h>
6 
main()7 int main() {
8   int *p = (int*)malloc(1024 * sizeof(int));
9   p[512] = 0;
10   free(p);
11 
12   p = (int*)malloc(128);
13   p = (int*)realloc(p, 2048 * sizeof(int));
14   p[1024] = 0;
15   free(p);
16 
17   p = (int*)calloc(16, sizeof(int));
18   if (p[8] != 0)
19     return 1;
20   p[15]++;
21   if (16 * sizeof(int) != _msize(p))
22     return 2;
23   free(p);
24 
25   p = new int;
26   *p = 42;
27   delete p;
28 
29   p = new int[42];
30   p[15]++;
31   delete [] p;
32 
33   printf("All ok\n");
34 // CHECK: All ok
35 
36   return 0;
37 }
38