BShelf: Fix crash in the case that view is NULL.

Also correct some formatting.
Fixes #12584.
This commit is contained in:
Augustin Cavalier
2016-01-12 14:30:13 -05:00
parent 03b1819c04
commit e2dfcf7094
+6 -5
View File
@@ -1498,15 +1498,16 @@ BShelf::_GetProperty(BMessage *msg, BMessage *reply)
for (int32 i = 0; i < CountReplicants(); i++) { for (int32 i = 0; i < CountReplicants(); i++) {
BView *view = NULL; BView *view = NULL;
ReplicantAt(i, &view, &ID, &err); ReplicantAt(i, &view, &ID, &err);
if (err == B_OK) { if (err != B_OK || view == NULL)
continue;
if (view->Name() != NULL && if (view->Name() != NULL &&
strlen(view->Name()) == strlen(name) && !strcmp(view->Name(), name)) { strlen(view->Name()) == strlen(name) &&
!strcmp(view->Name(), name)) {
replicant = view; replicant = view;
break; break;
} }
err = B_NAME_NOT_FOUND; err = B_NAME_NOT_FOUND;
} }
}
break; break;
} }
case B_ID_SPECIFIER: { case B_ID_SPECIFIER: {
@@ -1516,14 +1517,14 @@ BShelf::_GetProperty(BMessage *msg, BMessage *reply)
for (int32 i = 0; i < CountReplicants(); i++) { for (int32 i = 0; i < CountReplicants(); i++) {
BView *view = NULL; BView *view = NULL;
ReplicantAt(i, &view, &ID, &err); ReplicantAt(i, &view, &ID, &err);
if (err == B_OK) { if (err != B_OK || view == NULL)
continue;
if (ID == id) { if (ID == id) {
replicant = view; replicant = view;
break; break;
} }
err = B_NAME_NOT_FOUND; err = B_NAME_NOT_FOUND;
} }
}
break; break;
} }
default: default: