diff --git a/compiler-rt/lib/hwasan/hwasan_allocator.cpp b/compiler-rt/lib/hwasan/hwasan_allocator.cpp --- a/compiler-rt/lib/hwasan/hwasan_allocator.cpp +++ b/compiler-rt/lib/hwasan/hwasan_allocator.cpp @@ -94,8 +94,7 @@ } inline bool Metadata::IsAllocated() const { - return atomic_load(&chunk_state, memory_order_relaxed) == CHUNK_ALLOCATED && - GetRequestedSize(); + return atomic_load(&chunk_state, memory_order_relaxed) == CHUNK_ALLOCATED; } inline u64 Metadata::GetRequestedSize() const { diff --git a/compiler-rt/test/lsan/TestCases/malloc_zero.c b/compiler-rt/test/lsan/TestCases/malloc_zero.c --- a/compiler-rt/test/lsan/TestCases/malloc_zero.c +++ b/compiler-rt/test/lsan/TestCases/malloc_zero.c @@ -1,9 +1,6 @@ // RUN: %clang_lsan %s -o %t // RUN: %env_lsan_opts=use_stacks=0 not %run %t 2>&1 | FileCheck %s -// Fixme: remove once test passes with hwasan -// UNSUPPORTED: hwasan - /// Fails when only leak sanitizer is enabled // UNSUPPORTED: arm-linux, armhf-linux @@ -11,7 +8,7 @@ #include // CHECK: {{Leak|Address}}Sanitizer: detected memory leaks -// CHECK: {{Leak|Address}}Sanitizer: 1 byte(s) leaked in 1 allocation(s). +// CHECK: {{Leak|Address}}Sanitizer: {{0|1}} byte(s) leaked in 1 allocation(s). int main() { // The behavior of malloc(0) is implementation-defined.