Fix an emulator crash in Emulator::SaveSettings (#13567)

This commit is contained in:
Elad Ashkenazi 2023-03-21 11:12:39 +02:00 committed by GitHub
parent 7000ef4471
commit 7e6cc02e09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 3 deletions

View File

@ -3356,10 +3356,17 @@ void Emulator::SaveSettings(const std::string& settings, const std::string& titl
// Save config atomically
fs::pending_file temp(config_name);
temp.file.write(settings.c_str(), settings.size());
if (!temp.commit())
if (!temp.file)
{
sys_log.error("Could not save config to %s (error=%s)", config_name, fs::g_tls_error);
sys_log.error("Could not save config to %s (failed to create temporary file) (error=%s)", config_name, fs::g_tls_error);
}
else
{
temp.file.write(settings.c_str(), settings.size());
if (!temp.commit())
{
sys_log.error("Could not save config to %s (failed to commit) (error=%s)", config_name, fs::g_tls_error);
}
}
// Check if the running config/title is the same as the edited config/title.