23 lines · cpp
1// Check that we fill malloc-ed memory correctly.2// RUN: %clangxx_asan %s -o %t3// RUN: %run %t | FileCheck %s4// RUN: %env_asan_opts=max_malloc_fill_size=10:malloc_fill_byte=8 %run %t | FileCheck %s --check-prefix=CHECK-10-85// RUN: %env_asan_opts=max_malloc_fill_size=20:malloc_fill_byte=171 %run %t | FileCheck %s --check-prefix=CHECK-20-ab6 7#include <stdio.h>8int main(int argc, char **argv) {9 // With asan allocator this makes sure we get memory from mmap.10 static const int kSize = 1 << 25;11 unsigned char *x = new unsigned char[kSize];12 printf("-");13 for (int i = 0; i <= 32; i++) {14 printf("%02x", x[i]);15 }16 printf("-\n");17 delete [] x;18}19 20// CHECK: -bebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebe-21// CHECK-10-8: -080808080808080808080000000000000000000000000000000000000000000000-22// CHECK-20-ab: -abababababababababababababababababababab00000000000000000000000000-23