diff --git a/src/moonlight-server/exceptions/exceptions.h b/src/moonlight-server/exceptions/exceptions.h index 558e203a..284fb48d 100644 --- a/src/moonlight-server/exceptions/exceptions.h +++ b/src/moonlight-server/exceptions/exceptions.h @@ -16,7 +16,7 @@ static void safe_dump_stacktrace_to(const std::string &file_name) { cpptrace::frame_ptr buffer[N]; std::size_t count = cpptrace::safe_generate_raw_trace(buffer, N); if (count > 0) { - int fd = open(file_name.c_str(), O_WRONLY | O_CREAT | O_DSYNC); + int fd = open(file_name.c_str(), O_WRONLY | O_CREAT | O_DSYNC, 0666); if (fd <= 0) { return; } diff --git a/src/moonlight-server/wolf.cpp b/src/moonlight-server/wolf.cpp index 1020ff32..e68d6e6e 100644 --- a/src/moonlight-server/wolf.cpp +++ b/src/moonlight-server/wolf.cpp @@ -422,7 +422,9 @@ static void shutdown_handler(int signum) { static void check_exceptions() { auto stack_file = backtrace_file_src(); if (boost::filesystem::exists(stack_file)) { - load_stacktrace_from(stack_file)->resolve().print(); + if (auto object_trace = load_stacktrace_from(stack_file)) { + object_trace->resolve().print(); + } auto now = std::chrono::system_clock::now(); boost::filesystem::rename( stack_file, diff --git a/tests/testExceptions.cpp b/tests/testExceptions.cpp index 3dd7f9da..e523efce 100644 --- a/tests/testExceptions.cpp +++ b/tests/testExceptions.cpp @@ -7,10 +7,8 @@ using Catch::Matchers::Equals; TEST_CASE("Exceptions", "[Exceptions]") { safe_dump_stacktrace_to("stacktrace.txt"); + auto stacktrace = load_stacktrace_from("stacktrace.txt")->resolve(); - auto trace = load_stacktrace_from("stacktrace.txt"); - - auto stacktrace = trace->resolve(); REQUIRE(stacktrace.frames.size() > 0); stacktrace.print(std::cout, false);