Chromium Code Reviews| Index: base/process/memory_win.cc |
| diff --git a/base/process/memory_win.cc b/base/process/memory_win.cc |
| index 9d75efecacb21af8e9afbb857a1b560fa6c3f171..bf0c2c2e3c5bb0a691481dbbdea429bfb83e2850 100644 |
| --- a/base/process/memory_win.cc |
| +++ b/base/process/memory_win.cc |
| @@ -32,23 +32,31 @@ namespace { |
| #pragma warning(disable: 4702) |
| int OnNoMemory(size_t size) { |
| + // Custom exception code chosen to indicate an out of memory error. |
| + // See https://msdn.microsoft.com/en-us/library/het71c37.aspx. |
| + // "To make sure that you do not define a code that conflicts with an existing |
| + // exception code" ... "The resulting error code should therefore have the |
| + // highest four bits set to hexadecimal E." |
| + // 0xe0000008 was chosen arbitrarily as 0x00000008 is ERROR_NOT_ENOUGH_MEMORY. |
| + const DWORD kOomExceptionCode = 0xe0000008; |
|
Mark Mentovai
2016/07/21 21:15:11
Now you’ve got to update the comment in Breakpad t
|
| + |
| // Kill the process. This is important for security since most of code |
| // does not check the result of memory allocation. |
| // https://msdn.microsoft.com/en-us/library/het71c37.aspx |
| - ::RaiseException(win::kOomExceptionCode, EXCEPTION_NONCONTINUABLE, 0, |
| - nullptr); |
| + ::RaiseException(kOomExceptionCode, EXCEPTION_NONCONTINUABLE, 0, nullptr); |
| // Safety check, make sure process exits here. |
| - _exit(win::kOomExceptionCode); |
| + _exit(kOomExceptionCode); |
| return 0; |
| } |
| #pragma warning(pop) |
| -// HeapSetInformation function pointer. |
| -typedef BOOL (WINAPI* HeapSetFn)(HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T); |
| - |
| } // namespace |
| +void TerminateBecauseOutOfMemory(size_t size) { |
| + OnNoMemory(size); |
| +} |
| + |
| void EnableTerminationOnHeapCorruption() { |
| // Ignore the result code. Supported on XP SP3 and Vista. |
| HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); |