diff options
Diffstat (limited to 'lib/lsan/lsan_allocator.cc')
-rw-r--r-- | lib/lsan/lsan_allocator.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/lsan/lsan_allocator.cc b/lib/lsan/lsan_allocator.cc index 1512c2e85..f7eee1314 100644 --- a/lib/lsan/lsan_allocator.cc +++ b/lib/lsan/lsan_allocator.cc @@ -20,6 +20,8 @@ #include "sanitizer_common/sanitizer_stacktrace.h" #include "lsan_common.h" +extern "C" void *memset(void *ptr, int value, uptr num); + namespace __lsan { static const uptr kMaxAllowedMallocSize = 8UL << 30; @@ -34,7 +36,7 @@ struct ChunkMetadata { }; typedef SizeClassAllocator64<kAllocatorSpace, kAllocatorSize, - sizeof(ChunkMetadata), CompactSizeClassMap> PrimaryAllocator; + sizeof(ChunkMetadata), DefaultSizeClassMap> PrimaryAllocator; typedef SizeClassAllocatorLocalCache<PrimaryAllocator> AllocatorCache; typedef LargeMmapAllocator<> SecondaryAllocator; typedef CombinedAllocator<PrimaryAllocator, AllocatorCache, @@ -80,7 +82,10 @@ void *Allocate(const StackTrace &stack, uptr size, uptr alignment, Report("WARNING: LeakSanitizer failed to allocate %zu bytes\n", size); return 0; } - void *p = allocator.Allocate(&cache, size, alignment, cleared); + void *p = allocator.Allocate(&cache, size, alignment, false); + // Do not rely on the allocator to clear the memory (it's slow). + if (cleared && allocator.FromPrimary(p)) + memset(p, 0, size); RegisterAllocation(stack, p, size); return p; } |