xref: /aosp_15_r20/external/compiler-rt/test/asan/TestCases/huge_negative_hea_oob.cc (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1 // RUN: %clangxx_asan %s -o %t && not %run %t 2>&1 | FileCheck %s
2 // RUN: %clangxx_asan -O %s -o %t && not %run %t 2>&1 | FileCheck %s
3 // Check that we can find huge buffer overflows to the left.
4 #include <stdlib.h>
5 #include <string.h>
main(int argc,char ** argv)6 int main(int argc, char **argv) {
7   char *x = (char*)malloc(1 << 20);
8   memset(x, 0, 10);
9   int res = x[-argc * 4000];  // BOOOM
10   // CHECK: is located 4000 bytes to the left of
11   free(x);
12   return res;
13 }
14