From: Renato Golin Date: Wed, 27 Aug 2014 21:58:56 +0000 (+0000) Subject: Avoid zero length memset error X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=96c845a36c38866329edd42850a6f0c541692724;p=oota-llvm.git 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 --- diff --git a/include/llvm/Support/Allocator.h b/include/llvm/Support/Allocator.h index 5f3b284532d..9ea57039a84 100644 --- a/include/llvm/Support/Allocator.h +++ b/include/llvm/Support/Allocator.h @@ -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); }