xref: /llvm-project/compiler-rt/test/gwp_asan/double_free.cpp (revision a62586846fa90054bd9224912b07095d2fca662c)
121184ec5SMitch Phillips // REQUIRES: gwp_asan
221184ec5SMitch Phillips // RUN: %clangxx_gwp_asan %s -o %t
3*a6258684SMitch Phillips // RUN: %expect_crash %run %t 2>&1 | FileCheck %s
421184ec5SMitch Phillips 
521184ec5SMitch Phillips #include <cstdlib>
621184ec5SMitch Phillips 
main()721184ec5SMitch Phillips int main() {
87339ca27SMitch Phillips   // CHECK: GWP-ASan detected a memory error
9*a6258684SMitch Phillips   // CHECK: Double Free at 0x{{[a-f0-9]+}} (a 10-byte allocation)
1021184ec5SMitch Phillips   void *Ptr = malloc(10);
117339ca27SMitch Phillips 
1221184ec5SMitch Phillips   free(Ptr);
1321184ec5SMitch Phillips   free(Ptr);
1421184ec5SMitch Phillips   return 0;
1521184ec5SMitch Phillips }
16