mirror of
https://github.com/overte-org/overte.git
synced 2025-04-15 19:39:20 +02:00
Fix invalid iterator access
This commit is contained in:
parent
e12ca2683f
commit
a2c94bd9d2
1 changed files with 12 additions and 1 deletions
|
@ -279,7 +279,7 @@ void AssetsBackupHandler::recoverBackup(const QString& backupName, QuaZip& zip)
|
|||
qCWarning(asset_backup) << "Current asset mappings that might be stale.";
|
||||
}
|
||||
|
||||
const auto it = find_if(begin(_backups), end(_backups), [&](const AssetServerBackup& backup) {
|
||||
auto it = find_if(begin(_backups), end(_backups), [&](const AssetServerBackup& backup) {
|
||||
return backup.name == backupName;
|
||||
});
|
||||
if (it == end(_backups)) {
|
||||
|
@ -306,6 +306,17 @@ void AssetsBackupHandler::recoverBackup(const QString& backupName, QuaZip& zip)
|
|||
writeAssetFile(asset, zipFile.readAll());
|
||||
}
|
||||
}
|
||||
|
||||
// iterator is end() and has been invalidated in the `loadBackup` call
|
||||
// grab the new iterator
|
||||
it = find_if(begin(_backups), end(_backups), [&](const AssetServerBackup& backup) {
|
||||
return backup.name == backupName;
|
||||
});
|
||||
|
||||
if (it == end(_backups)) {
|
||||
qCCritical(asset_backup) << "Failed to recover backup:" << backupName;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const auto& newMappings = it->mappings;
|
||||
|
|
Loading…
Reference in a new issue