blob: f4afe7d79bfcdfcabf1b68c8327cbd6bb54c3218 [file] [log] [blame]
Kostya Serebryany707894b2016-08-02 22:25:38 +00001// 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
Kostya Kortchinsky8d6257b2017-02-03 20:49:42 +00009#include <assert.h>
Kostya Serebryany707894b2016-08-02 22:25:38 +000010#include <malloc.h>
Kostya Kortchinsky8d6257b2017-02-03 20:49:42 +000011#include <stdlib.h>
Kostya Serebryany707894b2016-08-02 22:25:38 +000012
13extern "C" const char* __scudo_default_options() {
14 return "DeallocationTypeMismatch=0"; // Defaults to true in scudo_flags.inc.
15}
16
17int main(int argc, char **argv)
18{
19 int *p = (int *)malloc(16);
Kostya Kortchinsky8d6257b2017-02-03 20:49:42 +000020 assert(p);
Kostya Serebryany707894b2016-08-02 22:25:38 +000021 delete p;
22 return 0;
23}
24
25// CHECK: ERROR: allocation type mismatch on address