1 // Make sure the zones created by malloc_create_zone() are write-protected. 2 #include <malloc/malloc.h> 3 #include <stdio.h> 4 5 // RUN: %clangxx_asan %s -o %t 6 // RUN: not %run %t 2>&1 | FileCheck %s 7 8 pwn(malloc_zone_t * unused_zone,size_t unused_size)9void *pwn(malloc_zone_t *unused_zone, size_t unused_size) { 10 printf("PWNED\n"); 11 return NULL; 12 } 13 main()14int main() { 15 malloc_zone_t *zone = malloc_create_zone(0, 0); 16 zone->malloc = pwn; 17 void *v = malloc_zone_malloc(zone, 1); 18 // CHECK-NOT: PWNED 19 return 0; 20 } 21