xref: /aosp_15_r20/external/llvm-libc/test/integration/scudo/gwp_asan_should_crash.cpp (revision 71db0c75aadcf003ffe3238005f61d7618a3fead)
1 //===-- libc gwp asan crash test ------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include <stdlib.h>
10 
main()11 int main() {
12   char retval = 0;
13   for (unsigned i = 0; i < 0x10000; ++i) {
14     char *Ptr = reinterpret_cast<char *>(malloc(10));
15 
16     for (unsigned i = 0; i < 10; ++i) {
17       *(Ptr + i) = 0x0;
18     }
19 
20     free(Ptr);
21     volatile char x = *Ptr;
22     retval = retval + x;
23   }
24   return retval;
25 }
26