xref: /llvm-project/compiler-rt/test/asan/TestCases/Windows/heapalloc_doublefree.cpp (revision 5ad8bbee238f9655c55f048b6ae8c9b40b4c87e5)
1 // RUN: %clang_cl_asan %Od %s %Fe%t
2 // RUN: %env_asan_opts=windows_hook_rtl_allocators=true not %run %t 2>&1 | FileCheck %s
3 // UNSUPPORTED: asan-64-bits
4 #include <cassert>
5 #include <windows.h>
6 
main()7 int main() {
8   void *allocation = HeapAlloc(GetProcessHeap(), 0, 10);
9   assert(allocation != 0);
10   assert(HeapFree(GetProcessHeap(), 0, allocation));
11   HeapFree(GetProcessHeap(), 0, allocation); //will dump
12   assert(0 && "HeapFree double free should produce an ASAN dump\n");
13   return 0;
14 }
15 
16 // CHECK: AddressSanitizer: attempting double-free on [[addr:0x[0-9a-fA-F]+]] in thread T0:
17