[llvm] r216624 - Avoid zero length memset error
Renato Golin
renato.golin at linaro.org
Wed Aug 27 14:58:56 PDT 2014
Author: rengolin
Date: Wed Aug 27 16:58:56 2014
New Revision: 216624
URL: http://llvm.org/viewvc/llvm-project?rev=216624&view=rev
Log:
Avoid zero length memset error
Adding a check on buffer lenght to avoid a __warn_memset_zero_len
warning on GCC 4.8.2.
Modified:
llvm/trunk/include/llvm/Support/Allocator.h
Modified: llvm/trunk/include/llvm/Support/Allocator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Allocator.h?rev=216624&r1=216623&r2=216624&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Allocator.h (original)
+++ llvm/trunk/include/llvm/Support/Allocator.h Wed Aug 27 16:58:56 2014
@@ -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);
}
More information about the llvm-commits
mailing list