Move ASan lit-tests under test/asan
[blocksruntime.git] / test / asan / TestCases / Darwin / malloc_zone-protected.cc
blobd5f6c7c12e67a12fdccdc8922a4965d3a218aaea
1 // Make sure the zones created by malloc_create_zone() are write-protected.
2 #include <malloc/malloc.h>
3 #include <stdio.h>
5 // RUN: %clangxx_asan %s -o %t
6 // RUN: not %t 2>&1 | FileCheck %s
9 void *pwn(malloc_zone_t *unused_zone, size_t unused_size) {
10 printf("PWNED\n");
11 return NULL;
14 int 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;