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 // On Windows, defining strtoll results in linker errors.
9 // XFAIL: freebsd,win32
10 #include <stdlib.h>
11 #include <stdio.h>
12 
strtol(const char * nptr,char ** endptr,int base)13 extern "C" long strtol(const char *nptr, char **endptr, int base) {
14   fprintf(stderr, "my_strtol_interceptor\n");
15   return 0;
16 }
17 
main()18 int main() {
19   char *x = (char*)malloc(10 * sizeof(char));
20   free(x);
21   return (int)strtol(x, 0, 10);
22   // CHECK: my_strtol_interceptor
23   // CHECK-NOT: heap-use-after-free
24 }
25