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.
This commit is contained in:
lat9nq
2021-06-02 15:05:45 -04:00
parent 377cd301b3
commit c41451af75
7 changed files with 27 additions and 18 deletions

View File

@ -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;