1 // RUN: %clangxx_asan -O0 %s -o %t
2 // RUN: %env_asan_opts=allocator_may_return_null=0 not %run %t 2>&1 | FileCheck %s
3 // RUN: %env_asan_opts=allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NULL
5 // REQUIRES: stable-runtime
11 void *p
= calloc(-1, 1000);
12 // CHECK: {{ERROR: AddressSanitizer: calloc parameters overflow: count \* size \(.* \* 1000\) cannot be represented in type size_t}}
13 // CHECK: {{#0 0x.* in .*calloc}}
14 // CHECK: {{#1 0x.* in main .*calloc-overflow.cpp:}}[[@LINE-3]]
15 // CHECK: SUMMARY: AddressSanitizer: calloc-overflow
17 printf("calloc returned: %zu\n", (size_t)p
);
18 // CHECK-NULL: calloc returned: 0