From 53440fd390c3e7ead14ba657a5fe06c0f8986f9b Mon Sep 17 00:00:00 2001 From: coryrc Date: Sun, 10 Aug 2025 18:59:01 -0700 Subject: [PATCH] Don't overwrite config if the new one was not successfully written (#10284) * Don't overwrite config if the new one was not successfully written The errors weren't being checked, now they are. Fixes #10283 --- src/libslic3r/AppConfig.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libslic3r/AppConfig.cpp b/src/libslic3r/AppConfig.cpp index 59e236db38..9f174740dc 100644 --- a/src/libslic3r/AppConfig.cpp +++ b/src/libslic3r/AppConfig.cpp @@ -837,6 +837,10 @@ void AppConfig::save() #endif c.close(); + if (c.fail()) { + BOOST_LOG_TRIVIAL(error) << "Failed to write new configuration to " << path_pid << "; aborting attempt to overwrite original configuration"; + return; + } #ifdef WIN32 // Make a backup of the configuration file before copying it to the final destination. @@ -1042,6 +1046,10 @@ void AppConfig::save() c << appconfig_md5_hash_line(config_str); #endif c.close(); + if (c.fail()) { + BOOST_LOG_TRIVIAL(error) << "Failed to write new configuration to " << path_pid << "; aborting attempt to overwrite original configuration"; + return; + } #ifdef WIN32 // Make a backup of the configuration file before copying it to the final destination.