summaryrefslogtreecommitdiffstats
path: root/base/process_util_win.cc
diff options
context:
space:
mode:
Diffstat (limited to 'base/process_util_win.cc')
-rw-r--r--base/process_util_win.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/base/process_util_win.cc b/base/process_util_win.cc
index 8a2eafe..315a68f 100644
--- a/base/process_util_win.cc
+++ b/base/process_util_win.cc
@@ -94,6 +94,15 @@ void AttachToConsole() {
std::ios::sync_with_stdio();
}
+void OnNoMemory() {
+ // Kill the process. This is important for security, since WebKit doesn't
+ // NULL-check many memory allocations. If a malloc fails, returns NULL, and
+ // the buffer is then used, it provides a handy mapping of memory starting at
+ // address 0 for an attacker to utilize.
+ __debugbreak();
+ _exit(1);
+}
+
} // namespace
ProcessId GetCurrentProcId() {
@@ -822,6 +831,10 @@ void EnableTerminationOnHeapCorruption() {
HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
}
+void EnableTerminationOnOutOfMemory() {
+ std::set_new_handler(&OnNoMemory);
+}
+
bool EnableInProcessStackDumping() {
// Add stack dumping support on exception on windows. Similar to OS_POSIX
// signal() handling in process_util_posix.cc.