1 | // RUN: %clang_cl_asan %Od %s %Fe%t |
2 | // RUN: %run %t | FileCheck %s |
3 | |
4 | #include <malloc.h> |
5 | #include <stdio.h> |
6 | |
7 | int main() { |
8 | int *p = (int*)malloc(size: 1024 * sizeof(int)); |
9 | p[512] = 0; |
10 | free(ptr: p); |
11 | |
12 | p = (int*)malloc(size: 128); |
13 | p = (int*)realloc(ptr: p, size: 2048 * sizeof(int)); |
14 | p[1024] = 0; |
15 | free(ptr: p); |
16 | |
17 | p = (int*)calloc(nmemb: 16, size: 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(ptr: 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(format: "All ok\n" ); |
34 | // CHECK: All ok |
35 | |
36 | return 0; |
37 | } |
38 | |