Make sure the memory range is writable before memset'ing it.
authorEvan Cheng <evan.cheng@apple.com>
Wed, 9 Sep 2009 01:45:24 +0000 (01:45 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Wed, 9 Sep 2009 01:45:24 +0000 (01:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81308 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/Allocator.cpp

index 36da4432073a20487898f339b97ab68209b4ca45..7a3fd87c17eef50cc5b2248b5ac8e6408ac48380 100644 (file)
@@ -15,6 +15,7 @@
 #include "llvm/Support/DataTypes.h"
 #include "llvm/Support/Recycler.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/System/Memory.h"
 #include <cstring>
 
 namespace llvm {
@@ -60,6 +61,7 @@ void BumpPtrAllocator::DeallocateSlabs(MemSlab *Slab) {
 #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(Slab + 1, Slab->Size - sizeof(MemSlab));
     memset(Slab + 1, 0xCD, Slab->Size - sizeof(MemSlab));
 #endif
     Allocator.Deallocate(Slab);