From 7e6cc02e093738dda8b20f3383240f6b7eaa2e0a Mon Sep 17 00:00:00 2001 From: Elad Ashkenazi Date: Tue, 21 Mar 2023 11:12:39 +0200 Subject: [PATCH] Fix an emulator crash in Emulator::SaveSettings (#13567) --- rpcs3/Emu/System.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 9ed39b4d54..cb7c2f4bdf 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -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.