• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Sanity checking a test in pure C.
2 // RUN: %clang -g -faddress-sanitizer -O2 %s -o %t
3 // RUN: %t 2>&1 | %symbolize | FileCheck %s
4 
5 // Sanity checking a test in pure C with -pie.
6 // RUN: %clang -g -faddress-sanitizer -O2 %s -pie -o %t
7 // RUN: %t 2>&1 | %symbolize | FileCheck %s
8 
9 #include <stdlib.h>
main()10 int main() {
11   char *x = (char*)malloc(10 * sizeof(char));
12   free(x);
13   return x[5];
14   // CHECK: heap-use-after-free
15   // CHECK: free
16   // CHECK: main{{.*}}sanity_check_pure_c.c:12
17   // CHECK: malloc
18   // CHECK: main{{.*}}sanity_check_pure_c.c:11
19 }
20