[ASan/Win] Add more tests for operator new[]
[blocksruntime.git] / test / asan / TestCases / Windows / intercept_memcpy.cc
blob4e52b1a90e7417597ea65bdfb93581ea749b1934
1 // RUN: %clangxx_asan -O0 %s -Fe%t
2 // FIXME: 'cat' is needed due to PR19744.
3 // RUN: not %run %t 2>&1 | cat | FileCheck %s
5 #include <stdio.h>
6 #include <string.h>
8 void call_memcpy(void* (*f)(void *, const void *, size_t),
9 void *a, const void *b, size_t c) {
10 f(a, b, c);
13 int main() {
14 char buff1[6] = "Hello", buff2[5];
16 call_memcpy(&memcpy, buff2, buff1, 5);
17 if (buff1[2] != buff2[2])
18 return 2;
19 printf("Initial test OK\n");
20 fflush(0);
21 // CHECK: Initial test OK
23 call_memcpy(&memcpy, buff2, buff1, 6);
24 // CHECK: AddressSanitizer: stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
25 // CHECK: WRITE of size 6 at [[ADDR]] thread T0
26 // CHECK: __asan_memcpy
27 // CHECK-NEXT: call_memcpy
28 // CHECK: main {{.*}}intercept_memcpy.cc:[[@LINE-5]]
29 // CHECK: Address [[ADDR]] is located in stack of thread T0 at offset {{.*}} in frame
30 // CHECK-NEXT: #0 {{.*}} main
31 // CHECK: 'buff2' <== Memory access at offset {{.*}} overflows this variable