| 1 | // RUN: %clangxx_scudo %s -o %t |
| 2 | // RUN: %run %t 2>&1 |
| 3 | // RUN: %env_scudo_opts=DeallocationTypeMismatch=0 %run %t 2>&1 |
| 4 | // RUN: %env_scudo_opts=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 <assert.h> |
| 10 | #include <malloc.h> |
| 11 | #include <stdlib.h> |
| 12 | |
| 13 | extern "C" const char *__scudo_default_options() { |
| 14 | return "DeallocationTypeMismatch=0" ; // Defaults to true in scudo_flags.inc. |
| 15 | } |
| 16 | |
| 17 | int main(int argc, char **argv) { |
| 18 | int *p = (int *)malloc(size: 16); |
| 19 | assert(p); |
| 20 | delete p; |
| 21 | return 0; |
| 22 | } |
| 23 | |
| 24 | // CHECK: ERROR: allocation type mismatch when deallocating address |
| 25 | |