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
FindPanel::GetDefaultAttrName(BString &result, int32 row) const
FindPanel::GetDefaultAttrName(BString& attrName, int32 row) const
{
BMenuItem* item = NULL;
BMenuField* menuField
= dynamic_cast<BMenuField*>(fAttrGrid->ItemAt(0, row)->View());
if (menuField->Menu() != NULL)
if (menuField != NULL && menuField->Menu() != NULL)
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();
else
item = NULL;
if (item != NULL)
result << " " << item->Label() << " ";
attrName << " " << item->Label() << " ";
else
result << " = ";
attrName << " = ";
BTextControl* textControl
= dynamic_cast<BTextControl*>(fAttrGrid->ItemAt(2, row)->View());