From 36e1394ccf04e61dec6f591161f0f219c1abd48a Mon Sep 17 00:00:00 2001 From: Philippe Saint-Pierre Date: Sat, 26 Nov 2011 20:57:22 -0500 Subject: [PATCH] Fix possible resource leakage * Also use the std::nothrow behaviour of operator new * and remove extra indent Fix CID 10948 --- .../appearance/DecorSettingsView.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/preferences/appearance/DecorSettingsView.cpp b/src/preferences/appearance/DecorSettingsView.cpp index 5dd5f6b82e..bbfdb165b9 100644 --- a/src/preferences/appearance/DecorSettingsView.cpp +++ b/src/preferences/appearance/DecorSettingsView.cpp @@ -95,7 +95,9 @@ DecorSettingsView::MessageReceived(BMessage *msg) if (msg->FindString("decor", &newDecor) != B_OK) break; - DecorInfoUtility* decorUtility = new DecorInfoUtility(); + DecorInfoUtility* decorUtility + = new(std::nothrow) DecorInfoUtility(); + if (decorUtility == NULL) return; @@ -113,7 +115,9 @@ DecorSettingsView::MessageReceived(BMessage *msg) } case kMsgDecorInfo: { - DecorInfoUtility* decorUtility = new DecorInfoUtility(); + DecorInfoUtility* decorUtility + = new(std::nothrow) DecorInfoUtility(); + if (decorUtility == NULL) return; @@ -203,12 +207,16 @@ DecorSettingsView::_SetCurrentDecor() void DecorSettingsView::SetDefaults() { - DecorInfoUtility* decorUtility = new DecorInfoUtility(); - if (decorUtility == NULL) - return; + DecorInfoUtility* decorUtility + = new(std::nothrow) DecorInfoUtility(); + + if (decorUtility == NULL) + return; DecorInfo* defaultDecorator(decorUtility->DefaultDecorator()); decorUtility->SetDecorator(defaultDecorator); _BuildDecorMenu(); + + delete decorUtility; }