153770e78SNico Weber // RUN: %clangxx_hwasan -O0 %s -o %t 253770e78SNico Weber // RUN: %env_hwasan_opts=allocator_may_return_null=0 not %run %t 2>&1 | FileCheck %s 353770e78SNico Weber // RUN: %env_hwasan_opts=allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NULL 453770e78SNico Weber 553770e78SNico Weber // UNSUPPORTED: android 653770e78SNico Weber 753770e78SNico Weber // REQUIRES: stable-runtime 853770e78SNico Weber 953770e78SNico Weber #include <stdio.h> 1053770e78SNico Weber #include <stdlib.h> 1153770e78SNico Weber 1253770e78SNico Weber extern void *aligned_alloc(size_t alignment, size_t size); 1353770e78SNico Weber main()1453770e78SNico Weberint main() { 1553770e78SNico Weber void *p = aligned_alloc(17, 100); 1653770e78SNico Weber // CHECK: ERROR: HWAddressSanitizer: invalid alignment requested in aligned_alloc: 17 1753770e78SNico Weber // CHECK: {{#0 0x.* in .*}}{{aligned_alloc|memalign}} 18efba6421SVitaly Buka // CHECK: {{#1 0x.* in main .*aligned_alloc-alignment.cpp:}}[[@LINE-3]] 1953770e78SNico Weber // CHECK: SUMMARY: HWAddressSanitizer: invalid-aligned-alloc-alignment 2053770e78SNico Weber 21*96a4167bSMatt Morehouse printf("pointer after failed aligned_alloc: %zd\n", (size_t)p); 2253770e78SNico Weber // CHECK-NULL: pointer after failed aligned_alloc: 0 2353770e78SNico Weber 2453770e78SNico Weber return 0; 2553770e78SNico Weber } 26