mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-16 19:21:18 +02:00
Fix use after free in deleteMappings
This commit is contained in:
parent
abbe263142
commit
a4b9945226
2 changed files with 6 additions and 7 deletions
|
@ -953,16 +953,15 @@ void AssetServer::removeBakedPathsForDeletedAsset(AssetHash hash) {
|
||||||
deleteMappings(hiddenBakedFolder);
|
deleteMappings(hiddenBakedFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AssetServer::deleteMappings(AssetPathList& paths) {
|
bool AssetServer::deleteMappings(const AssetPathList& paths) {
|
||||||
// take a copy of the current mappings in case persistence of these deletes fails
|
// take a copy of the current mappings in case persistence of these deletes fails
|
||||||
auto oldMappings = _fileMappings;
|
auto oldMappings = _fileMappings;
|
||||||
|
|
||||||
QSet<QString> hashesToCheckForDeletion;
|
QSet<QString> hashesToCheckForDeletion;
|
||||||
|
|
||||||
// enumerate the paths to delete and remove them all
|
// enumerate the paths to delete and remove them all
|
||||||
for (auto& path : paths) {
|
for (const auto& rawPath : paths) {
|
||||||
|
auto path = rawPath.trimmed();
|
||||||
path = path.trimmed();
|
|
||||||
|
|
||||||
// figure out if this path will delete a file or folder
|
// figure out if this path will delete a file or folder
|
||||||
if (pathIsFolder(path)) {
|
if (pathIsFolder(path)) {
|
||||||
|
@ -991,12 +990,12 @@ bool AssetServer::deleteMappings(AssetPathList& paths) {
|
||||||
} else {
|
} else {
|
||||||
auto it = _fileMappings.find(path);
|
auto it = _fileMappings.find(path);
|
||||||
if (it != _fileMappings.end()) {
|
if (it != _fileMappings.end()) {
|
||||||
_fileMappings.erase(it);
|
|
||||||
|
|
||||||
// add this hash to the list we need to check for asset removal from server
|
// add this hash to the list we need to check for asset removal from server
|
||||||
hashesToCheckForDeletion << it->second;
|
hashesToCheckForDeletion << it->second;
|
||||||
|
|
||||||
qCDebug(asset_server) << "Deleted a mapping:" << path << "=>" << it->second;
|
qCDebug(asset_server) << "Deleted a mapping:" << path << "=>" << it->second;
|
||||||
|
|
||||||
|
_fileMappings.erase(it);
|
||||||
} else {
|
} else {
|
||||||
qCDebug(asset_server) << "Unable to delete a mapping that was not found:" << path;
|
qCDebug(asset_server) << "Unable to delete a mapping that was not found:" << path;
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ private:
|
||||||
bool setMapping(AssetPath path, AssetHash hash);
|
bool setMapping(AssetPath path, AssetHash hash);
|
||||||
|
|
||||||
/// Delete mapping `path`. Returns `true` if deletion of mappings succeeds, else `false`.
|
/// Delete mapping `path`. Returns `true` if deletion of mappings succeeds, else `false`.
|
||||||
bool deleteMappings(AssetPathList& paths);
|
bool deleteMappings(const AssetPathList& paths);
|
||||||
|
|
||||||
/// Rename mapping from `oldPath` to `newPath`. Returns true if successful
|
/// Rename mapping from `oldPath` to `newPath`. Returns true if successful
|
||||||
bool renameMapping(AssetPath oldPath, AssetPath newPath);
|
bool renameMapping(AssetPath oldPath, AssetPath newPath);
|
||||||
|
|
Loading…
Reference in a new issue