1*5ad8bbeeSAlvin Wong // RUN: %clang_cl_asan %Od %s %Fe%t 2673dc3d4SNico Weber // RUN: %env_asan_opts=windows_hook_rtl_allocators=true not %run %t 2>&1 | FileCheck %s 3673dc3d4SNico Weber // UNSUPPORTED: asan-64-bits 4673dc3d4SNico Weber #include <stdio.h> 5673dc3d4SNico Weber #include <windows.h> 6673dc3d4SNico Weber main()7673dc3d4SNico Weberint main() { 8673dc3d4SNico Weber char *oldbuf; 9673dc3d4SNico Weber size_t sz = 8; 10673dc3d4SNico Weber HANDLE procHeap = GetProcessHeap(); 11673dc3d4SNico Weber oldbuf = (char *)HeapAlloc(procHeap, 0, sz); 12673dc3d4SNico Weber char *newbuf = oldbuf; 13673dc3d4SNico Weber while (oldbuf == newbuf) { 14673dc3d4SNico Weber sz *= 2; 15673dc3d4SNico Weber newbuf = (char *)HeapReAlloc(procHeap, 0, oldbuf, sz); 16673dc3d4SNico Weber } 17673dc3d4SNico Weber 18673dc3d4SNico Weber newbuf[0] = 'a'; 19673dc3d4SNico Weber oldbuf[0] = 'a'; 20673dc3d4SNico Weber // CHECK: AddressSanitizer: heap-use-after-free on address [[ADDR:0x[0-9a-f]+]] 21673dc3d4SNico Weber // CHECK: WRITE of size 1 at [[WRITE2:0x[0-9a-f]+]] thread T0 22673dc3d4SNico Weber // CHECK: #0 {{0x[0-9a-f]+ in main.*}}:[[@LINE-3]] 23673dc3d4SNico Weber } 24