150
|
1 // RUN: %clangxx_scudo %s -o %t
|
|
2 // RUN: not %run %t malloc 2>&1 | FileCheck %s
|
|
3 // RUN: not %run %t new 2>&1 | FileCheck %s
|
|
4 // RUN: not %run %t newarray 2>&1 | FileCheck %s
|
|
5
|
|
6 // Tests double-free error on pointers allocated with different allocation
|
|
7 // functions.
|
|
8
|
|
9 #include <assert.h>
|
|
10 #include <stdlib.h>
|
|
11 #include <string.h>
|
|
12
|
221
|
13 int main(int argc, char **argv) {
|
150
|
14 assert(argc == 2);
|
|
15 if (!strcmp(argv[1], "malloc")) {
|
|
16 void *p = malloc(sizeof(int));
|
|
17 assert(p);
|
|
18 free(p);
|
|
19 free(p);
|
|
20 }
|
|
21 if (!strcmp(argv[1], "new")) {
|
|
22 int *p = new int;
|
|
23 assert(p);
|
|
24 delete p;
|
|
25 delete p;
|
|
26 }
|
|
27 if (!strcmp(argv[1], "newarray")) {
|
|
28 int *p = new int[8];
|
|
29 assert(p);
|
|
30 delete[] p;
|
|
31 delete[] p;
|
|
32 }
|
|
33 return 0;
|
|
34 }
|
|
35
|
|
36 // CHECK: ERROR: invalid chunk state
|