brintos

brintos / llvm-project-archived public Read only

0
0
Text · 695 B · 5d715e3 Raw
24 lines · cpp
1// RUN: %clang_cl_asan %Od %s %Fe%t2// RUN: %env_asan_opts=windows_hook_rtl_allocators=true not %run %t 2>&1 | FileCheck %s3// UNSUPPORTED: asan-64-bits4#include <stdio.h>5#include <windows.h>6 7int main() {8  char *oldbuf;9  size_t sz = 8;10  HANDLE procHeap = GetProcessHeap();11  oldbuf = (char *)HeapAlloc(procHeap, 0, sz);12  char *newbuf = oldbuf;13  while (oldbuf == newbuf) {14    sz *= 2;15    newbuf = (char *)HeapReAlloc(procHeap, 0, oldbuf, sz);16  }17 18  newbuf[0] = 'a';19  oldbuf[0] = 'a';20  // CHECK: AddressSanitizer: heap-use-after-free on address [[ADDR:0x[0-9a-f]+]]21  // CHECK: WRITE of size 1 at [[WRITE2:0x[0-9a-f]+]] thread T022  // CHECK: #0 {{0x[0-9a-f]+ in main.*}}:[[@LINE-3]]23}24