1 // RUN: %clang_scudo %s -o %t
2 // RUN:                                              %run %t 2>&1
3 // RUN: SCUDO_OPTIONS=DeallocationTypeMismatch=0     %run %t 2>&1
4 // RUN: SCUDO_OPTIONS=DeallocationTypeMismatch=1 not %run %t 2>&1 | FileCheck %s
5 
6 // Tests that the options can be passed using getScudoDefaultOptions, and that
7 // the environment ones take precedence over them.
8 
9 #include <stdlib.h>
10 #include <malloc.h>
11 
12 extern "C" const char* __scudo_default_options() {
13   return "DeallocationTypeMismatch=0";  // Defaults to true in scudo_flags.inc.
14 }
15 
16 int main(int argc, char **argv)
17 {
18   int *p = (int *)malloc(16);
19   if (!p)
20     return 1;
21   delete p;
22   return 0;
23 }
24 
25 // CHECK: ERROR: allocation type mismatch on address
26