Skip to content

Commit

Permalink
fix: open requires mode when creating the file
Browse files Browse the repository at this point in the history
  • Loading branch information
ABeltramo committed Jan 22, 2024
1 parent c372e73 commit dcf91e2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/moonlight-server/exceptions/exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 3 additions & 1 deletion src/moonlight-server/wolf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 1 addition & 3 deletions tests/testExceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit dcf91e2

Please sign in to comment.