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 19:11:14 +00:00
parent 25ea14c965
commit 9e5cfa8b96
15 changed files with 142 additions and 94 deletions
@@ -170,7 +170,12 @@ void EnvironmentEditor::on_deleteButton_clicked()
if(!sel)
return;
delete ui->variables->takeTopLevelItem(ui->variables->indexOfTopLevelItem(sel));
int idx = ui->variables->indexOfTopLevelItem(sel);
if(idx >= 0)
delete ui->variables->takeTopLevelItem(idx);
else
qCritical() << "Can't find item to delete";
on_name_textChanged(ui->name->text());
}
+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();