mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-27 08:05:42 +00:00
Add safety to satisfy Coverity on some errors that are likely impossible
* Reported by Coverity Scan
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user