Fix possible resource leakage and NULL dereference
* Use the std::nothrow behaviour of operator new * Avoid to compare the CurrentDecorator at every iteration * Avoid possible NULL dereference Fix CID 10947 and CID 10889
This commit is contained in:
@@ -162,7 +162,7 @@ DecorSettingsView::_BuildDecorMenu()
|
|||||||
DecorInfo* decorator = NULL;
|
DecorInfo* decorator = NULL;
|
||||||
|
|
||||||
// collect the current system decor settings
|
// collect the current system decor settings
|
||||||
DecorInfoUtility* decorUtility = new DecorInfoUtility();
|
DecorInfoUtility* decorUtility = new(std::nothrow) DecorInfoUtility();
|
||||||
|
|
||||||
if (decorUtility == NULL) {
|
if (decorUtility == NULL) {
|
||||||
return;
|
return;
|
||||||
@@ -174,21 +174,20 @@ DecorSettingsView::_BuildDecorMenu()
|
|||||||
if (decorator == NULL) {
|
if (decorator == NULL) {
|
||||||
fprintf(stderr, "Decorator : error NULL entry @ %li / %li\n",
|
fprintf(stderr, "Decorator : error NULL entry @ %li / %li\n",
|
||||||
i, count);
|
i, count);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
BString decorName = decorator->Name();
|
BString decorName = decorator->Name();
|
||||||
|
|
||||||
if (decorUtility->CurrentDecorator() == decorator)
|
|
||||||
fCurrentDecor = (char*)decorName.String();
|
|
||||||
|
|
||||||
BMessage* message = new BMessage(kMsgSetDecor);
|
BMessage* message = new BMessage(kMsgSetDecor);
|
||||||
message->AddString("decor", decorator->Name());
|
message->AddString("decor", decorName);
|
||||||
|
|
||||||
BMenuItem* item
|
BMenuItem* item = new BMenuItem(decorName, message);
|
||||||
= new BMenuItem(decorator->Name(), message);
|
|
||||||
|
|
||||||
fDecorMenu->AddItem(item);
|
fDecorMenu->AddItem(item);
|
||||||
}
|
}
|
||||||
|
fCurrentDecor = (char*)decorUtility->CurrentDecorator()->Name().String();
|
||||||
|
delete decorUtility;
|
||||||
|
|
||||||
_SetCurrentDecor();
|
_SetCurrentDecor();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user