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) { |