brintos

brintos / llvm-project-archived public Read only

0
0
Text · 435 B · 912f8f7 Raw
21 lines · cpp
1// REQUIRES: gwp_asan2// RUN: %clangxx_gwp_asan %s -o %t3// RUN: %expect_crash %run %t 2>&1 | FileCheck %s4 5// CHECK: GWP-ASan detected a memory error6// CHECK: Use After Free at 0x{{[a-f0-9]+}} (0 bytes into a 10-byte allocation7 8#include <cstdlib>9 10int main() {11  char *Ptr = reinterpret_cast<char *>(malloc(10));12 13  for (unsigned i = 0; i < 10; ++i) {14    *(Ptr + i) = 0x0;15  }16 17  free(Ptr);18  volatile char x = *Ptr;19  return 0;20}21