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