diff options
author | Kostya Serebryany <kcc@google.com> | 2013-01-16 09:12:14 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2013-01-16 09:12:14 +0000 |
commit | b7062cec53cc13411dc15c91815967763dffd61c (patch) | |
tree | bece8cb675317ab5d1e4dd8ae9c58d1bb1496a32 | |
parent | daffc0dd4cf5af361bd921668eb3a217d393fdc8 (diff) | |
download | bcm5719-llvm-b7062cec53cc13411dc15c91815967763dffd61c.tar.gz bcm5719-llvm-b7062cec53cc13411dc15c91815967763dffd61c.zip |
[asan] asan_allocator2: fix the memalign handling (clear the first word of allocated chunk in case there is an old memalign magic)
llvm-svn: 172603
-rw-r--r-- | compiler-rt/lib/asan/asan_allocator2.cc | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/compiler-rt/lib/asan/asan_allocator2.cc b/compiler-rt/lib/asan/asan_allocator2.cc index f94314b2f72..bc953969af6 100644 --- a/compiler-rt/lib/asan/asan_allocator2.cc +++ b/compiler-rt/lib/asan/asan_allocator2.cc @@ -347,6 +347,8 @@ static void *Allocate(uptr size, uptr alignment, StackTrace *stack, allocated = allocator.Allocate(cache, needed_size, 8, false); } uptr alloc_beg = reinterpret_cast<uptr>(allocated); + // Clear the first allocated word (an old kMemalignMagic may still be there). + reinterpret_cast<uptr *>(alloc_beg)[0] = 0; uptr alloc_end = alloc_beg + needed_size; uptr beg_plus_redzone = alloc_beg + rz_size; uptr user_beg = beg_plus_redzone; |