• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // If user provides his own libc functions, ASan doesn't
2 // intercept these functions.
3 
4 // RUN: %clangxx_asan -O0 %s -o %t && %run %t 2>&1 | FileCheck %s
5 // RUN: %clangxx_asan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
6 // RUN: %clangxx_asan -O2 %s -o %t && %run %t 2>&1 | FileCheck %s
7 // RUN: %clangxx_asan -O3 %s -o %t && %run %t 2>&1 | FileCheck %s
8 #include <stdlib.h>
9 #include <stdio.h>
10 
strtol(const char * nptr,char ** endptr,int base)11 extern "C" long strtol(const char *nptr, char **endptr, int base) {
12   fprintf(stderr, "my_strtol_interceptor\n");
13   return 0;
14 }
15 
main()16 int main() {
17   char *x = (char*)malloc(10 * sizeof(char));
18   free(x);
19   return (int)strtol(x, 0, 10);
20   // CHECK: my_strtol_interceptor
21   // CHECK-NOT: heap-use-after-free
22 }
23