annotate compiler-rt/test/scudo/double-free.cpp @ 222:81f6424ef0e3 llvm-original

LLVM original branch
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 18 Jul 2021 22:10:01 +0900
parents 79ff65ed7e25
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clangxx_scudo %s -o %t
anatofuz
parents:
diff changeset
2 // RUN: not %run %t malloc 2>&1 | FileCheck %s
anatofuz
parents:
diff changeset
3 // RUN: not %run %t new 2>&1 | FileCheck %s
anatofuz
parents:
diff changeset
4 // RUN: not %run %t newarray 2>&1 | FileCheck %s
anatofuz
parents:
diff changeset
5
anatofuz
parents:
diff changeset
6 // Tests double-free error on pointers allocated with different allocation
anatofuz
parents:
diff changeset
7 // functions.
anatofuz
parents:
diff changeset
8
anatofuz
parents:
diff changeset
9 #include <assert.h>
anatofuz
parents:
diff changeset
10 #include <stdlib.h>
anatofuz
parents:
diff changeset
11 #include <string.h>
anatofuz
parents:
diff changeset
12
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
13 int main(int argc, char **argv) {
150
anatofuz
parents:
diff changeset
14 assert(argc == 2);
anatofuz
parents:
diff changeset
15 if (!strcmp(argv[1], "malloc")) {
anatofuz
parents:
diff changeset
16 void *p = malloc(sizeof(int));
anatofuz
parents:
diff changeset
17 assert(p);
anatofuz
parents:
diff changeset
18 free(p);
anatofuz
parents:
diff changeset
19 free(p);
anatofuz
parents:
diff changeset
20 }
anatofuz
parents:
diff changeset
21 if (!strcmp(argv[1], "new")) {
anatofuz
parents:
diff changeset
22 int *p = new int;
anatofuz
parents:
diff changeset
23 assert(p);
anatofuz
parents:
diff changeset
24 delete p;
anatofuz
parents:
diff changeset
25 delete p;
anatofuz
parents:
diff changeset
26 }
anatofuz
parents:
diff changeset
27 if (!strcmp(argv[1], "newarray")) {
anatofuz
parents:
diff changeset
28 int *p = new int[8];
anatofuz
parents:
diff changeset
29 assert(p);
anatofuz
parents:
diff changeset
30 delete[] p;
anatofuz
parents:
diff changeset
31 delete[] p;
anatofuz
parents:
diff changeset
32 }
anatofuz
parents:
diff changeset
33 return 0;
anatofuz
parents:
diff changeset
34 }
anatofuz
parents:
diff changeset
35
anatofuz
parents:
diff changeset
36 // CHECK: ERROR: invalid chunk state