From 5c3dd954465e8e3db3ac44183d230e1b77f78134 Mon Sep 17 00:00:00 2001 From: brain Date: Thu, 16 Mar 2006 18:09:04 +0000 Subject: Catch std::bad_alloc program wide (to catch out nazi sysadmins who restrict machines to small memory sizes, and expect things to still run fine :p) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3722 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/inspircd.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 1df6ee293..aed513737 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -26,6 +26,9 @@ using namespace std; #include #include #include +#include +#include +#include #ifdef GCC3 #include #else @@ -829,9 +832,18 @@ int InspIRCd::Run() int main(int argc, char** argv) { - ServerInstance = new InspIRCd(argc, argv); - ServerInstance->Run(); - delete ServerInstance; - return 0; + try + { + ServerInstance = new InspIRCd(argc, argv); + ServerInstance->Run(); + delete ServerInstance; + } + catch (std::bad_alloc) + { + log(DEFAULT,"You are out of memory! (got exception std::bad_alloc!)"); + send_error("**** OUT OF MEMORY **** We're gonna need a bigger boat!"); + printf("Out of memory! (got exception std::bad_alloc!"); + } + return 0; } -- cgit v1.2.3