summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_allocator.h
diff options
context:
space:
mode:
authorSergey Matveev <earthdok@google.com>2013-11-24 14:45:38 +0000
committerSergey Matveev <earthdok@google.com>2013-11-24 14:45:38 +0000
commitbad15f4a277829fd9326f369ead3b0bff64912b9 (patch)
treef1af6380f325691cdede604f03f6c49069dfeaed /lib/sanitizer_common/sanitizer_allocator.h
parent3d0deab266106ebb1fa5169deab1a545238e6b24 (diff)
downloadcompiler-rt-bad15f4a277829fd9326f369ead3b0bff64912b9.tar.gz
[sanitizer] Do not clear memory which comes from secondary allocator.
Secondary allocator is mmap-based, so the memory is already zeroed. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@195571 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_allocator.h')
-rw-r--r--lib/sanitizer_common/sanitizer_allocator.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/sanitizer_common/sanitizer_allocator.h b/lib/sanitizer_common/sanitizer_allocator.h
index 81e40ed15..5ea1edbc7 100644
--- a/lib/sanitizer_common/sanitizer_allocator.h
+++ b/lib/sanitizer_common/sanitizer_allocator.h
@@ -1184,13 +1184,14 @@ class CombinedAllocator {
if (alignment > 8)
size = RoundUpTo(size, alignment);
void *res;
- if (primary_.CanAllocate(size, alignment))
+ bool from_primary = primary_.CanAllocate(size, alignment);
+ if (from_primary)
res = cache->Allocate(&primary_, primary_.ClassID(size));
else
res = secondary_.Allocate(&stats_, size, alignment);
if (alignment > 8)
CHECK_EQ(reinterpret_cast<uptr>(res) & (alignment - 1), 0);
- if (cleared && res)
+ if (cleared && res && from_primary)
internal_bzero_aligned16(res, RoundUpTo(size, 16));
return res;
}