Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(847)

Unified Diff: base/process/memory_win.cc

Issue 885443002: Roll Chrome into Mojo. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebase to ToT mojo Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/process/kill_posix.cc ('k') | base/process/process.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process/memory_win.cc
diff --git a/base/process/memory_win.cc b/base/process/memory_win.cc
index 668214ceaf073bf604f1d2afbe233d9805c4355d..fc57b48f1f768ccbeec35dfdef0e358c11533600 100644
--- a/base/process/memory_win.cc
+++ b/base/process/memory_win.cc
@@ -4,6 +4,7 @@
#include "base/process/memory.h"
+#include <new.h>
#include <psapi.h>
#include "base/logging.h"
@@ -13,15 +14,19 @@ namespace base {
namespace {
-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.
+#pragma warning(push)
+#pragma warning(disable: 4702)
+
+int OnNoMemory(size_t) {
+ // Kill the process. This is important for security since most of code
+ // does not check the result of memory allocation.
__debugbreak();
_exit(1);
+ return 0;
}
+#pragma warning(pop)
+
// HeapSetInformation function pointer.
typedef BOOL (WINAPI* HeapSetFn)(HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T);
@@ -68,7 +73,8 @@ void EnableTerminationOnHeapCorruption() {
}
void EnableTerminationOnOutOfMemory() {
- std::set_new_handler(&OnNoMemory);
+ _set_new_handler(&OnNoMemory);
+ _set_new_mode(1);
}
HMODULE GetModuleFromAddress(void* address) {
« no previous file with comments | « base/process/kill_posix.cc ('k') | base/process/process.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698