1 // Sanity checking a test in pure C. 2 // RUN: %clang_asan -O2 %s -o %t 3 // RUN: not %run %t 2>&1 | FileCheck %s 4 5 // Sanity checking a test in pure C with -pie. 6 // RUN: %clang_asan -O2 %s -pie -fPIE -o %t 7 // RUN: not %run %t 2>&1 | FileCheck %s 8 // XFAIL: arm-linux-gnueabi 9 // XFAIL: armv7l-unknown-linux-gnueabihf 10 11 #include <stdlib.h> 12 int main() { 13 char *x = (char*)malloc(10 * sizeof(char)); 14 free(x); 15 return x[5]; 16 // CHECK: heap-use-after-free 17 // CHECK: free 18 // CHECK: main{{.*}}sanity_check_pure_c.c:[[@LINE-4]] 19 // CHECK: malloc 20 // CHECK: main{{.*}}sanity_check_pure_c.c:[[@LINE-7]] 21 } 22