From 6997467eea5b79eec323fa681b373ef7295c9c7a Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Fri, 31 Dec 2010 17:17:19 +0000 Subject: [PATCH] Fix an instance where an allocation wasn't checked for success. Wrap call to SymbolLookup::Init() in a try/catch block since it could potentially throw an exception. This was causing the debugger to terminate in some instances. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40046 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/debug/debug_support.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/kits/debug/debug_support.cpp b/src/kits/debug/debug_support.cpp index c80bc3a78a..e5691fb6dc 100644 --- a/src/kits/debug/debug_support.cpp +++ b/src/kits/debug/debug_support.cpp @@ -353,24 +353,30 @@ debug_create_symbol_lookup_context(team_id team, // create the lookup context debug_symbol_lookup_context *lookupContext - = new(nothrow) debug_symbol_lookup_context; + = new(std::nothrow) debug_symbol_lookup_context; + if (lookupContext == NULL) + return B_NO_MEMORY; ObjectDeleter contextDeleter(lookupContext); // create and init symbol lookup - SymbolLookup *lookup = new(nothrow) SymbolLookup(team); - if (!lookup) + SymbolLookup *lookup = new(std::nothrow) SymbolLookup(team); + if (lookup == NULL) return B_NO_MEMORY; + ObjectDeleter lookupDeleter(lookup); - status_t error = lookup->Init(); - if (error != B_OK) { - delete lookup; - return error; + try { + status_t error = lookup->Init(); + if (error != B_OK) + return error; + } catch (BPrivate::Debug::Exception exception) { + return exception.Error(); } // everything went fine: return the result lookupContext->lookup = lookup; *_lookupContext = lookupContext; contextDeleter.Detach(); + lookupDeleter.Detach(); return B_OK; }