diff options
author | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-29 15:53:45 +0000 |
---|---|---|
committer | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-29 15:53:45 +0000 |
commit | 47ba21131301f6c34778eaa5a020a4ded6527244 (patch) | |
tree | 07c1f783de870f327325d6dfcce04d71702d4a3d | |
parent | e288a8e7c2b0b1faf93d925128c84620a044bdba (diff) | |
download | chromium_src-47ba21131301f6c34778eaa5a020a4ded6527244.zip chromium_src-47ba21131301f6c34778eaa5a020a4ded6527244.tar.gz chromium_src-47ba21131301f6c34778eaa5a020a4ded6527244.tar.bz2 |
Add a hook for using the std::set_new_handler().
This is what tcmalloc uses to hook out-of-memory cases.
Review URL: http://codereview.chromium.org/99090
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14847 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/chrome_dll_main.cc | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/chrome/app/chrome_dll_main.cc b/chrome/app/chrome_dll_main.cc index 78d2e98..e77eddd 100644 --- a/chrome/app/chrome_dll_main.cc +++ b/chrome/app/chrome_dll_main.cc @@ -109,17 +109,12 @@ void PureCall() { __debugbreak(); } -int OnNoMemory(size_t memory_size) { +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(); - - // Return memory_size so it is not optimized out. Make sure the return value - // is at least 1 so malloc/new is retried, especially useful when under a - // debugger. - return memory_size ? static_cast<int>(memory_size) : 1; } // Handlers to silently dump the current process when there is an assert in @@ -199,9 +194,7 @@ void RegisterInvalidParamHandler() { _set_invalid_parameter_handler(InvalidParameter); _set_purecall_handler(PureCall); // Gather allocation failure. - _set_new_handler(&OnNoMemory); - // Make sure malloc() calls the new handler too. - _set_new_mode(1); + std::set_new_handler(&OnNoMemory); #endif } |