diff --git a/compiler-rt/test/asan/TestCases/Windows/heaprealloc_alloc_zero.cpp b/compiler-rt/test/asan/TestCases/Windows/heaprealloc_alloc_zero.cpp index 8b0bc71b9f5db..6a5f8a1e7ea09 100644 --- a/compiler-rt/test/asan/TestCases/Windows/heaprealloc_alloc_zero.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/heaprealloc_alloc_zero.cpp @@ -1,15 +1,20 @@ // RUN: %clang_cl_asan %Od %MT -o %t %s // RUN: %env_asan_opts=windows_hook_rtl_allocators=true %run %t 2>&1 | FileCheck %s -// UNSUPPORTED: asan-64-bits #include #include +#include #include int main() { void *ptr = malloc(0); if (ptr) std::cerr << "allocated!\n"; - ((char *)ptr)[0] = '\xff'; //check this 'allocate 1 instead of 0' hack hasn't changed + + // Check the 'allocate 1 instead of 0' hack hasn't changed + // Note that as of b3452d90b043a398639e62b0ab01aa339cc649de, dereferencing + // the pointer will be detected as a heap-buffer-overflow. + if (__sanitizer_get_allocated_size(ptr) != 1) + return 1; free(ptr);