diff options
author | lat9nq <22451773+lat9nq@users.noreply.github.com> | 2021-06-02 15:05:45 -0400 |
---|---|---|
committer | lat9nq <22451773+lat9nq@users.noreply.github.com> | 2021-06-02 19:50:20 -0400 |
commit | c41451af75520a19b050347bb9c267b69773ff0a (patch) | |
tree | ba77ef44510bcc5e31bc686328f3f9d152bbafb4 /src/yuzu/main.cpp | |
parent | 377cd301b30aaee015d6981387284ab5cbd7cc3e (diff) |
yuzu qt: Revert some usages of string_view
Causes a heap-use-after free reported by AddressSanitizer. This makes
use of std::filesystem::path, but due to that we have to use their
string() function which may not work for all characters.
Diffstat (limited to 'src/yuzu/main.cpp')
-rw-r--r-- | src/yuzu/main.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index dd8dd32333..237e26829b 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -1334,8 +1334,9 @@ void GMainWindow::BootGame(const QString& filename, std::size_t program_index) { if (!(loader == nullptr || loader->ReadProgramId(title_id) != Loader::ResultStatus::Success)) { // Load per game settings + const auto file_path = std::filesystem::path{filename.toStdU16String()}; const auto config_file_name = title_id == 0 - ? Common::FS::GetFilename(filename.toStdString()) + ? Common::FS::PathToUTF8String(file_path.filename()) : fmt::format("{:016X}", title_id); Config per_game_config(config_file_name, Config::ConfigType::PerGameConfig); } @@ -1799,7 +1800,7 @@ void GMainWindow::RemoveAddOnContent(u64 program_id, const QString& entry_type) } void GMainWindow::OnGameListRemoveFile(u64 program_id, GameListRemoveTarget target, - std::string_view game_path) { + const std::string& game_path) { const QString question = [this, target] { switch (target) { case GameListRemoveTarget::ShaderCache: @@ -1846,10 +1847,11 @@ void GMainWindow::RemoveTransferableShaderCache(u64 program_id) { } } -void GMainWindow::RemoveCustomConfiguration(u64 program_id, std::string_view game_path) { - const auto config_file_name = program_id == 0 - ? fmt::format("{:s}.ini", Common::FS::GetFilename(game_path)) - : fmt::format("{:016X}.ini", program_id); +void GMainWindow::RemoveCustomConfiguration(u64 program_id, const std::string& game_path) { + const auto file_path = std::filesystem::path(Common::FS::ToU8String(game_path)); + const auto config_file_name = + program_id == 0 ? Common::FS::PathToUTF8String(file_path.filename()).append(".ini") + : fmt::format("{:016X}.ini", program_id); const auto custom_config_file_path = Common::FS::GetYuzuPath(Common::FS::YuzuPath::ConfigDir) / "custom" / config_file_name; |