29 lines · cpp
1// Check that without suppressions, we catch the issue.2// RUN: %clangxx_asan -O0 %s -o %t3// RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-CRASH %s4 5// RUN: echo "interceptor_via_fun:crash_function" > %t.supp6// RUN: %clangxx_asan -O0 %s -o %t && %env_asan_opts=suppressions='"%t.supp"' %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s7 8// UNSUPPORTED: ios9 10#include <stdio.h>11#include <stdlib.h>12#include <string.h>13 14void crash_function() {15 char *a = (char *)malloc(6);16 free(a);17 size_t len = strlen(a); // BOOM18 fprintf(stderr, "strlen ignored, len = %zu\n", len);19}20 21int main() {22 crash_function();23}24 25// CHECK-CRASH: AddressSanitizer: heap-use-after-free26// CHECK-CRASH-NOT: strlen ignored27// CHECK-IGNORE-NOT: AddressSanitizer: heap-use-after-free28// CHECK-IGNORE: strlen ignored29