brintos

brintos / llvm-project-archived public Read only

0
0
Text · 457 B · 00dc018 Raw
18 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: Buffer Overflow at 0x{{[a-f0-9]+}} ({{[1-9][0-9]*}} bytes to the right7// CHECK-SAME: of a {{[1-9][0-9]*}}-byte allocation8 9#include <cstdlib>10 11#include "page_size.h"12 13int main() {14  char *Ptr = reinterpret_cast<char *>(malloc(pageSize()));15  volatile char x = *(Ptr + pageSize());16  return 0;17}18