From c6ea5b0cd1728a044a4c5b3c8f1bf35e1d8d2847 Mon Sep 17 00:00:00 2001 From: Kirill Stoimenov Date: Mon, 6 Feb 2023 23:53:48 +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/lib/hwasan/hwasan_allocator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler-rt/lib/hwasan/hwasan_allocator.cpp b/compiler-rt/lib/hwasan/hwasan_allocator.cpp index 9373ea2..ec52741 100644 --- a/compiler-rt/lib/hwasan/hwasan_allocator.cpp +++ b/compiler-rt/lib/hwasan/hwasan_allocator.cpp @@ -163,7 +163,7 @@ static uptr TaggedSize(uptr size) { static void *HwasanAllocate(StackTrace *stack, uptr orig_size, uptr alignment, bool zeroise) { // Keep this consistent with LSAN and ASAN behavior. - if (orig_size == 0) + if (UNLIKELY(orig_size == 0)) orig_size = 1; if (orig_size > kMaxAllowedMallocSize) { if (AllocatorMayReturnNull()) { -- 2.7.4