aboutsummaryrefslogtreecommitdiffstats
path: root/src/3rdparty
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@digia.com>2014-10-21 16:51:56 +0200
committerUlf Hermann <ulf.hermann@digia.com>2014-10-30 13:19:41 +0100
commit78ac7ecbd4af02e989d3f391cf0f3627f93fd12c (patch)
tree24b026687d614dc4215114f5f62f6b22867fbaa5 /src/3rdparty
parent2ffb01b45d51b23c834f9f81060f17d3fd90b800 (diff)
Implement guard pages for windows page allocator
Change-Id: Ia54a259bbf05cca7dc1ed868a75931efa95851b3 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/3rdparty')
-rw-r--r--src/3rdparty/masm/wtf/OSAllocatorWin.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/3rdparty/masm/wtf/OSAllocatorWin.cpp b/src/3rdparty/masm/wtf/OSAllocatorWin.cpp
index f95a4841c6..bcd1f6df04 100644
--- a/src/3rdparty/masm/wtf/OSAllocatorWin.cpp
+++ b/src/3rdparty/masm/wtf/OSAllocatorWin.cpp
@@ -25,6 +25,7 @@
#include "config.h"
#include "OSAllocator.h"
+#include "PageBlock.h"
#if OS(WINDOWS)
@@ -48,11 +49,20 @@ void* OSAllocator::reserveUncommitted(size_t bytes, Usage, bool writable, bool e
return result;
}
-void* OSAllocator::reserveAndCommit(size_t bytes, Usage, bool writable, bool executable, bool)
+void* OSAllocator::reserveAndCommit(size_t bytes, Usage, bool writable, bool executable,
+ bool includesGuardPages)
{
void* result = VirtualAlloc(0, bytes, MEM_RESERVE | MEM_COMMIT, protection(writable, executable));
if (!result)
CRASH();
+ if (includesGuardPages) {
+ size_t guardSize = pageSize();
+ DWORD oldProtect;
+ if (!VirtualProtect(result, guardSize, protection(false, false), &oldProtect) ||
+ !VirtualProtect(static_cast<char*>(result) + bytes - guardSize, guardSize,
+ protection(false, false), &oldProtect))
+ CRASH();
+ }
return result;
}