Add safety to satisfy Coverity on some errors that are likely impossible

* Reported by Coverity Scan
This commit is contained in:
baldurk
2017-11-22 12:21:46 +00:00
parent 25ea14c965
commit 9e5cfa8b96
15 changed files with 142 additions and 94 deletions
+4 -2
View File
@@ -640,8 +640,10 @@ void RemoteManager::on_deleteHost_clicked()
RemoteHost *host = getRemoteHost(item);
int itemIdx = ui->hosts->indexOfTopLevelItem(item);
// don't delete running instances on a host
if(item->parent() != ui->hosts->invisibleRootItem() || !host)
if(item->parent() != ui->hosts->invisibleRootItem() || itemIdx < 0 || !host)
return;
QString hostname = item->text(0);
@@ -664,7 +666,7 @@ void RemoteManager::on_deleteHost_clicked()
item->clear();
queueDelete(ui->hosts->takeTopLevelItem(ui->hosts->indexOfTopLevelItem(item)));
queueDelete(ui->hosts->takeTopLevelItem(itemIdx));
ui->hosts->clearSelection();