brintos

brintos / llvm-project-archived public Read only

0
0
Text · 518 B · 11a8b38 Raw
23 lines · cpp
1// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s2 3#include <string.h>4 5namespace XXX {6struct YYY {7  static int ZZZ(int x) {8    char array[10];9    memset(array, 0, 10);10    return array[x];  // BOOOM11    // CHECK: ERROR: AddressSanitizer: stack-buffer-overflow12    // CHECK: READ of size 1 at13    // CHECK: is located in stack of thread T0 at offset14    // CHECK: XXX::YYY::ZZZ15  }16};17}  // namespace XXX18 19int main(int argc, char **argv) {20  int res = XXX::YYY::ZZZ(argc + 10);21  return res;22}23