From 197ea64be37bf1aeadde177a9e2d8bedcab8775c Mon Sep 17 00:00:00 2001 From: "mbelshe@google.com" Date: Thu, 11 Jun 2009 18:05:18 +0000 Subject: Enable the _set_new_mode() call so that calls to malloc behave like calls to new, and will go through the std_new_handler on crash. For chrome, this means that all out of memory conditions, be they malloc induced or new induced will cause the process to abort. BUG=11475 TEST=none Review URL: http://codereview.chromium.org/122041 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18180 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/app/chrome_dll_main.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'chrome/app/chrome_dll_main.cc') diff --git a/chrome/app/chrome_dll_main.cc b/chrome/app/chrome_dll_main.cc index ad9c77b..c41c95b 100644 --- a/chrome/app/chrome_dll_main.cc +++ b/chrome/app/chrome_dll_main.cc @@ -201,6 +201,10 @@ static void SetUpGLibLogHandler() { } #endif // defined(OS_LINUX) +#if defined(OS_WIN) +extern "C" int _set_new_mode(int); +#endif + // Register the invalid param handler and pure call handler to be able to // notify breakpad when it happens. void RegisterInvalidParamHandler() { @@ -209,6 +213,8 @@ void RegisterInvalidParamHandler() { _set_purecall_handler(PureCall); // Gather allocation failure. std::set_new_handler(&OnNoMemory); + // Also enable the new handler for malloc() based failures. + _set_new_mode(1); #endif } -- cgit v1.1