[haiku-commits] haiku: hrev43329 - src/preferences/appearance

  • From: stpere@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 27 Nov 2011 03:00:54 +0100 (CET)

hrev43329 adds 1 changeset to branch 'master'
old head: 552d99013ab95709e7a8ecc7d34ef93c6e431f2f
new head: 36e1394ccf04e61dec6f591161f0f219c1abd48a

----------------------------------------------------------------------------

1 files changed, 13 insertions(+), 5 deletions(-)
src/preferences/appearance/DecorSettingsView.cpp |   18 +++++++++++++-----

############################################################################

Revision:    hrev43329
Commit:      36e1394ccf04e61dec6f591161f0f219c1abd48a
URL:         http://cgit.haiku-os.org/haiku/commit/?id=36e1394
Author:      Philippe Saint-Pierre <stpere@xxxxxxxxx>
Date:        Sun Nov 27 01:57:22 2011 UTC

Fix possible resource leakage

* Also use the std::nothrow behaviour of operator new
* and remove extra indent

Fix CID 10948

----------------------------------------------------------------------------

diff --git a/src/preferences/appearance/DecorSettingsView.cpp 
b/src/preferences/appearance/DecorSettingsView.cpp
index 5dd5f6b..bbfdb16 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;
 }
 
 


Other related posts:

  • » [haiku-commits] haiku: hrev43329 - src/preferences/appearance - stpere