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:
parent
36e1394ccf
commit
374d5a4c6d
@ -162,7 +162,7 @@ DecorSettingsView::_BuildDecorMenu()
|
||||
DecorInfo* decorator = NULL;
|
||||
|
||||
// collect the current system decor settings
|
||||
DecorInfoUtility* decorUtility = new DecorInfoUtility();
|
||||
DecorInfoUtility* decorUtility = new(std::nothrow) DecorInfoUtility();
|
||||
|
||||
if (decorUtility == NULL) {
|
||||
return;
|
||||
@ -174,21 +174,20 @@ DecorSettingsView::_BuildDecorMenu()
|
||||
if (decorator == NULL) {
|
||||
fprintf(stderr, "Decorator : error NULL entry @ %li / %li\n",
|
||||
i, count);
|
||||
continue;
|
||||
}
|
||||
|
||||
BString decorName = decorator->Name();
|
||||
|
||||
if (decorUtility->CurrentDecorator() == decorator)
|
||||
fCurrentDecor = (char*)decorName.String();
|
||||
|
||||
BMessage* message = new BMessage(kMsgSetDecor);
|
||||
message->AddString("decor", decorator->Name());
|
||||
message->AddString("decor", decorName);
|
||||
|
||||
BMenuItem* item
|
||||
= new BMenuItem(decorator->Name(), message);
|
||||
BMenuItem* item = new BMenuItem(decorName, message);
|
||||
|
||||
fDecorMenu->AddItem(item);
|
||||
}
|
||||
fCurrentDecor = (char*)decorUtility->CurrentDecorator()->Name().String();
|
||||
delete decorUtility;
|
||||
|
||||
_SetCurrentDecor();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user