VERY experimental Nintendo Switch 2 emulator
C++
reporter: Eliminate undefined behavior in SaveErrorReport
Lioncash97fd619312b5
diff --git a/src/core/reporter.cpp b/src/core/reporter.cppindex 6e21296f6a..543b91d9ac 100644--- a/src/core/reporter.cpp+++ b/src/core/reporter.cpp@@ -339,8 +339,8 @@ void Reporter::SavePlayReport(PlayReportType type, u64 title_id, std::vector<std}void Reporter::SaveErrorReport(u64 title_id, Result result,- std::optional<std::string> custom_text_main,- std::optional<std::string> custom_text_detail) const {+ const std::optional<std::string>& custom_text_main,+ const std::optional<std::string>& custom_text_detail) const {if (!IsReportingEnabled()) {return;}@@ -354,8 +354,8 @@ void Reporter::SaveErrorReport(u64 title_id, Result result,out["backtrace"] = GetBacktraceData(system);out["error_custom_text"] = {- {"main", *custom_text_main},- {"detail", *custom_text_detail},+ {"main", custom_text_main.value_or("")},+ {"detail", custom_text_detail.value_or("")},};SaveToFile(std::move(out), GetPath("error_report", title_id, timestamp));diff --git a/src/core/reporter.h b/src/core/reporter.hindex 68755cbdec..983a9545a1 100644--- a/src/core/reporter.h+++ b/src/core/reporter.h@@ -61,8 +61,8 @@ public:// Used by error appletvoid SaveErrorReport(u64 title_id, Result result,- std::optional<std::string> custom_text_main = {},- std::optional<std::string> custom_text_detail = {}) const;+ const std::optional<std::string>& custom_text_main = {},+ const std::optional<std::string>& custom_text_detail = {}) const;void SaveFSAccessLog(std::string_view log_message) const;