Avoid zero length memset error

Adding a check on buffer lenght to avoid a __warn_memset_zero_len
warning on GCC 4.8.2.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216624 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Renato Golin 2014-08-27 21:58:56 +00:00
parent a160df5b42
commit 96c845a36c

View File

@ -318,8 +318,10 @@ private:
#ifndef NDEBUG
// Poison the memory so stale pointers crash sooner. Note we must
// preserve the Size and NextPtr fields at the beginning.
sys::Memory::setRangeWritable(*I, AllocatedSlabSize);
memset(*I, 0xCD, AllocatedSlabSize);
if (AllocatedSlabSize != 0) {
sys::Memory::setRangeWritable(*I, AllocatedSlabSize);
memset(*I, 0xCD, AllocatedSlabSize);
}
#endif
Allocator.Deallocate(*I, AllocatedSlabSize);
}