mirror of
https://github.com/intel/llvm.git
synced 2026-01-19 09:31:59 +08:00
[hwasan] Do not memset allocation if it comes from the secondary allocator
The secondary allocator calls mmap which should return zero-inited pages, so we don't need to explicitly memset it with zeros. This is similar to what asan's calloc does. Differential Revision: https://reviews.llvm.org/D149285
This commit is contained in:
@@ -213,7 +213,10 @@ static void *HwasanAllocate(StackTrace *stack, uptr orig_size, uptr alignment,
|
||||
ReportOutOfMemory(size, stack);
|
||||
}
|
||||
if (zeroise) {
|
||||
internal_memset(allocated, 0, size);
|
||||
// The secondary allocator mmaps memory, which should be zero-inited so we
|
||||
// don't need to explicitly clear it.
|
||||
if (allocator.FromPrimary(allocated))
|
||||
internal_memset(allocated, 0, size);
|
||||
} else if (flags()->max_malloc_fill_size > 0) {
|
||||
uptr fill_size = Min(size, (uptr)flags()->max_malloc_fill_size);
|
||||
internal_memset(allocated, flags()->malloc_fill_byte, fill_size);
|
||||
|
||||
Reference in New Issue
Block a user