Skip to content

Commit df08efc

Browse files
committed
Merge 81308 from mainline.
Make sure the memory range is writable before memset'ing it. llvm-svn: 81638
1 parent c82b6db commit df08efc

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

llvm/lib/Support/Allocator.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "llvm/Support/DataTypes.h"
1616
#include "llvm/Support/Recycler.h"
1717
#include "llvm/Support/raw_ostream.h"
18+
#include "llvm/System/Memory.h"
1819
#include <cstring>
1920

2021
namespace llvm {
@@ -60,6 +61,7 @@ void BumpPtrAllocator::DeallocateSlabs(MemSlab *Slab) {
6061
#ifndef NDEBUG
6162
// Poison the memory so stale pointers crash sooner. Note we must
6263
// preserve the Size and NextPtr fields at the beginning.
64+
sys::Memory::setRangeWritable(Slab + 1, Slab->Size - sizeof(MemSlab));
6365
memset(Slab + 1, 0xCD, Slab->Size - sizeof(MemSlab));
6466
#endif
6567
Allocator.Deallocate(Slab);

0 commit comments

Comments
 (0)