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; }