| 1 | // RUN: %clang_lsan %s -o %t |
| 2 | // RUN: %env_lsan_opts=allocator_may_return_null=1:max_allocation_size_mb=16:use_stacks=0 not %run %t 2>&1 | FileCheck %s |
| 3 | |
| 4 | /// Fails when only leak sanitizer is enabled |
| 5 | // UNSUPPORTED: arm-linux, armhf-linux |
| 6 | |
| 7 | #include <assert.h> |
| 8 | #include <stdio.h> |
| 9 | #include <stdlib.h> |
| 10 | |
| 11 | // CHECK: {{.*}}Sanitizer failed to allocate 0x1000001 bytes |
| 12 | |
| 13 | // CHECK: {{.*}}Sanitizer: detected memory leaks |
| 14 | // CHECK: {{.*}}Sanitizer: 9 byte(s) leaked in 1 allocation(s). |
| 15 | |
| 16 | int main() { |
| 17 | char *p = malloc(size: 9); |
| 18 | fprintf(stderr, format: "nine: %p\n" , p); |
| 19 | assert(realloc(p, 0x1000001) == NULL); // 16MiB+1 |
| 20 | p = 0; |
| 21 | } |
| 22 | |