brintos

brintos / llvm-project-archived public Read only

0
0
Text · 609 B · c39292e Raw
22 lines · c
1// RUN: %clang_lsan %s -o %t2// RUN: %env_lsan_opts=allocator_may_return_null=1:max_allocation_size_mb=16:use_stacks=0 not %run %t 2>&1 | FileCheck %s3 4/// Fails when only leak sanitizer is enabled5// UNSUPPORTED: arm-linux, armhf-linux6 7#include <assert.h>8#include <stdio.h>9#include <stdlib.h>10 11// CHECK: {{.*}}Sanitizer failed to allocate 0x1000001 bytes12 13// CHECK: {{.*}}Sanitizer: detected memory leaks14// CHECK: {{.*}}Sanitizer: 9 byte(s) leaked in 1 allocation(s).15 16int main() {17  char *p = malloc(9);18  fprintf(stderr, "nine: %p\n", p);19  assert(realloc(p, 0x1000001) == NULL); // 16MiB+120  p = 0;21}22