[LVI] Add trunc to i1 handling. (#124480)
[llvm-project.git] / compiler-rt / test / asan / TestCases / Windows / rtlallocateheap.cpp
bloba34a18fc35e2b2c2114369d4a41a694b5ac82208
1 // RUN: %clang_cl_asan %Od %s %Fe%t %MD
2 // RUN: %env_asan_opts=windows_hook_rtl_allocators=true not %run %t 2>&1 | FileCheck %s
3 // UNSUPPORTED: asan-64-bits
5 #include <stdio.h>
6 #include <windows.h>
8 using AllocateFunctionPtr = PVOID(__stdcall *)(PVOID, ULONG, SIZE_T);
9 using FreeFunctionPtr = PVOID(__stdcall *)(PVOID, ULONG, PVOID);
11 int main() {
12 HMODULE NtDllHandle = GetModuleHandle("ntdll.dll");
13 if (!NtDllHandle) {
14 puts("Couldn't load ntdll??");
15 return -1;
18 auto RtlAllocateHeap_ptr = (AllocateFunctionPtr)GetProcAddress(NtDllHandle, "RtlAllocateHeap");
19 if (RtlAllocateHeap_ptr == 0) {
20 puts("Couldn't RtlAllocateHeap");
21 return -1;
24 char *buffer;
25 buffer = (char *)RtlAllocateHeap_ptr(GetProcessHeap(), 0, 32),
26 buffer[33] = 'a';
27 // CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
28 // CHECK: WRITE of size 1 at [[ADDR]] thread T0