ソースを参照

core/reporter: Return in error case in SaveToFile()

If the path couldn't be created, then we shouldn't be attempting to save
the file.
Lioncash 7 年 前
コミット
7ad11e3867
1 ファイル変更3 行追加1 行削除
  1. 3 1
      src/core/reporter.cpp

+ 3 - 1
src/core/reporter.cpp

@@ -31,8 +31,10 @@ std::string GetTimestamp() {
 using namespace nlohmann;
 using namespace nlohmann;
 
 
 void SaveToFile(const json& json, const std::string& filename) {
 void SaveToFile(const json& json, const std::string& filename) {
-    if (!FileUtil::CreateFullPath(filename))
+    if (!FileUtil::CreateFullPath(filename)) {
         LOG_ERROR(Core, "Failed to create path for '{}' to save report!", filename);
         LOG_ERROR(Core, "Failed to create path for '{}' to save report!", filename);
+        return;
+    }
 
 
     std::ofstream file(
     std::ofstream file(
         FileUtil::SanitizePath(filename, FileUtil::DirectorySeparator::PlatformDefault));
         FileUtil::SanitizePath(filename, FileUtil::DirectorySeparator::PlatformDefault));