Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Hotfix] sys_fs: fix map entry removal in destructor #13961

Merged
merged 1 commit into from Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions rpcs3/Emu/Cell/lv2/sys_fs.cpp
Expand Up @@ -145,7 +145,7 @@ lv2_fs_mount_info_map::lv2_fs_mount_info_map()
lv2_fs_mount_info_map::~lv2_fs_mount_info_map()
{
for (const auto& [path, info] : map)
vfs_unmount(path);
vfs_unmount(path, false); // Do not remove the value from the map we are iterating over.
}

bool lv2_fs_mount_info_map::remove(std::string_view path)
Expand Down Expand Up @@ -220,7 +220,7 @@ u64 lv2_fs_mount_info_map::get_all(CellFsMountInfo* info, u64 len) const
return count;
}

bool lv2_fs_mount_info_map::vfs_unmount(std::string_view vpath)
bool lv2_fs_mount_info_map::vfs_unmount(std::string_view vpath, bool remove_from_map)
{
const std::string local_path = vfs::get(vpath);

Expand All @@ -239,9 +239,9 @@ bool lv2_fs_mount_info_map::vfs_unmount(std::string_view vpath)
}
}

const auto result = vfs::unmount(vpath);
const bool result = vfs::unmount(vpath);

if (result)
if (result && remove_from_map)
g_fxo->get<lv2_fs_mount_info_map>().remove(vpath);

return result;
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/lv2/sys_fs.h
Expand Up @@ -216,7 +216,7 @@ struct lv2_fs_mount_info_map
const lv2_fs_mount_info& lookup(std::string_view path, bool no_cell_fs_path = false) const;
u64 get_all(CellFsMountInfo* info = nullptr, u64 len = 0) const;

static bool vfs_unmount(std::string_view vpath);
static bool vfs_unmount(std::string_view vpath, bool remove_from_map = true);

private:
std::unordered_map<std::string, lv2_fs_mount_info, fmt::string_hash, std::equal_to<>> map;
Expand Down