| 1 | // RUN: %clang_cl_asan %Od -o %t %s |
| 2 | // RUN: %env_asan_opts=windows_hook_rtl_allocators=true %run %t 2>&1 | FileCheck %s |
| 3 | // RUN: %env_asan_opts=windows_hook_rtl_allocators=false %run %t 2>&1 | FileCheck %s |
| 4 | // RUN: %clang_cl %Od -o %t %s |
| 5 | // RUN: %run %t 2>&1 | FileCheck %s |
| 6 | // UNSUPPORTED: asan-64-bits |
| 7 | #include <cassert> |
| 8 | #include <stdio.h> |
| 9 | #include<windows.h> |
| 10 | |
| 11 | int main() { |
| 12 | HANDLE heap = HeapCreate(0, 0, 0); |
| 13 | void *ptr = HeapAlloc(heap, 0, 4); |
| 14 | assert(ptr); |
| 15 | void *ptr2 = HeapReAlloc(heap, 0, ptr, 0); |
| 16 | assert(ptr2); |
| 17 | HeapFree(heap, 0, ptr2); |
| 18 | fprintf(stderr, format: "passed!\n" ); |
| 19 | } |
| 20 | |
| 21 | // CHECK-NOT: double-free |
| 22 | // CHECK-NOT: AddressSanitizer |
| 23 | // CHECK: passed! |
| 24 | |