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 <windows.h>
5
6int main() {
7 char *buffer;
8 buffer = (char *)HeapAlloc(GetProcessHeap(), 0, 32),
9 HeapFree(GetProcessHeap(), 0, buffer);
10 buffer[0] = 'a';
11 // CHECK: AddressSanitizer: heap-use-after-free on address [[ADDR:0x[0-9a-f]+]]
12 // CHECK: WRITE of size 1 at [[ADDR]] thread T0
13}
14

source code of compiler-rt/test/asan/TestCases/Windows/heapalloc_uaf.cpp