[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
This commit is contained in:
Kirill Stoimenov 2023-02-06 23:53:48 +00:00
parent 914f86949a
commit c6ea5b0cd1

View File

@ -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()) {