From 01176191d2fc3fd6807a362fec9702990a46a97c Mon Sep 17 00:00:00 2001 From: Kirill Stoimenov Date: Tue, 7 Feb 2023 00:34:26 +0000 Subject: [PATCH] [HWASAN] Modify HwasanAllocate to set the size to 1 if requested size is 0 This should keep it consistent with LSAN and ASAN, Reviewed By: vitalybuka, MaskRay Differential Revision: https://reviews.llvm.org/D143438 --- compiler-rt/test/hwasan/TestCases/malloc-test.c | 2 +- compiler-rt/test/hwasan/TestCases/new-test.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler-rt/test/hwasan/TestCases/malloc-test.c b/compiler-rt/test/hwasan/TestCases/malloc-test.c index 199464b..24fdfaa 100644 --- a/compiler-rt/test/hwasan/TestCases/malloc-test.c +++ b/compiler-rt/test/hwasan/TestCases/malloc-test.c @@ -11,6 +11,6 @@ int main() { __hwasan_enable_allocator_tagging(); char *a1 = (char*)malloc(0); assert(a1 != 0); - assert(__sanitizer_get_allocated_size(a1) == 0); + assert(__sanitizer_get_allocated_size(a1) == 1); free(a1); } diff --git a/compiler-rt/test/hwasan/TestCases/new-test.cpp b/compiler-rt/test/hwasan/TestCases/new-test.cpp index 7fd20f8..184c0a6 100644 --- a/compiler-rt/test/hwasan/TestCases/new-test.cpp +++ b/compiler-rt/test/hwasan/TestCases/new-test.cpp @@ -15,7 +15,7 @@ int main() { size_t volatile n = 0; char *a1 = new char[n]; assert(a1 != nullptr); - assert(__sanitizer_get_allocated_size(a1) == 0); + assert(__sanitizer_get_allocated_size(a1) == 1); delete[] a1; #if defined(__cpp_aligned_new) && \ -- 2.7.4