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 main(int argc,char ** argv)13int main(int argc, char **argv) 14 { 15 assert(argc == 2); 16 if (!strcmp(argv[1], "malloc")) { 17 void *p = malloc(sizeof(int)); 18 assert(p); 19 free(p); 20 free(p); 21 } 22 if (!strcmp(argv[1], "new")) { 23 int *p = new int; 24 assert(p); 25 delete p; 26 delete p; 27 } 28 if (!strcmp(argv[1], "newarray")) { 29 int *p = new int[8]; 30 assert(p); 31 delete[] p; 32 delete[] p; 33 } 34 return 0; 35 } 36 37 // CHECK: ERROR: invalid chunk state 38