Tracker: Dereference NULL pointer, CID 1032279

Also a bit of a refactor of GetDefaultAttrName(), check for NULL explicitly,
rename result to attrName
This commit is contained in:
John Scipione 2014-07-24 22:28:17 -04:00
parent 861d997e49
commit ce04484e6b
1 changed files with 10 additions and 9 deletions

View File

@ -2913,27 +2913,28 @@ FindPanel::AddMimeTypeAttrs(BMenu* menu)
void void
FindPanel::GetDefaultAttrName(BString &result, int32 row) const FindPanel::GetDefaultAttrName(BString& attrName, int32 row) const
{ {
BMenuItem* item = NULL; BMenuItem* item = NULL;
BMenuField* menuField BMenuField* menuField
= dynamic_cast<BMenuField*>(fAttrGrid->ItemAt(0, row)->View()); = dynamic_cast<BMenuField*>(fAttrGrid->ItemAt(0, row)->View());
if (menuField->Menu() != NULL) if (menuField != NULL && menuField->Menu() != NULL)
item = menuField->Menu()->FindMarked(); item = menuField->Menu()->FindMarked();
if (item != NULL)
result << item->Label();
else
result << B_TRANSLATE("Name");
if (item && item->Submenu() != NULL) if (item != NULL)
attrName << item->Label();
else
attrName << B_TRANSLATE("Name");
if (item != NULL && item->Submenu() != NULL)
item = item->Submenu()->FindMarked(); item = item->Submenu()->FindMarked();
else else
item = NULL; item = NULL;
if (item != NULL) if (item != NULL)
result << " " << item->Label() << " "; attrName << " " << item->Label() << " ";
else else
result << " = "; attrName << " = ";
BTextControl* textControl BTextControl* textControl
= dynamic_cast<BTextControl*>(fAttrGrid->ItemAt(2, row)->View()); = dynamic_cast<BTextControl*>(fAttrGrid->ItemAt(2, row)->View());