From ac9c39fa178d82d41256ea35b10284b4584f1f0a Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Thu, 9 Mar 2023 15:50:10 +0000 Subject: CrashReporter: Handle backtrace OOM errors --- Userland/Applications/CrashReporter/main.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'Userland/Applications') diff --git a/Userland/Applications/CrashReporter/main.cpp b/Userland/Applications/CrashReporter/main.cpp index eceba09693..e08df1d82e 100644 --- a/Userland/Applications/CrashReporter/main.cpp +++ b/Userland/Applications/CrashReporter/main.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, Linus Groh + * Copyright (c) 2020-2023, Linus Groh * Copyright (c) 2021, Andreas Kling * Copyright (c) 2022, Ali Chraghi * @@ -275,9 +275,16 @@ ErrorOr serenity_main(Main::Arguments arguments) GUI::MessageBox::show(window, DeprecatedString::formatted("Communication failed with FileSystemAccessServer: {}.", file_or_error.release_error()), "Saving backtrace failed"sv, GUI::MessageBox::Type::Error); return; } - auto file = file_or_error.release_value().release_stream(); - if (auto result = file->write(full_backtrace.to_byte_buffer()); result.is_error()) + + auto byte_buffer_or_error = full_backtrace.try_to_byte_buffer(); + if (byte_buffer_or_error.is_error()) { + GUI::MessageBox::show(window, DeprecatedString::formatted("Couldn't create backtrace: {}.", byte_buffer_or_error.release_error()), "Saving backtrace failed"sv, GUI::MessageBox::Type::Error); + return; + } + auto byte_buffer = byte_buffer_or_error.release_value(); + + if (auto result = file->write(byte_buffer); result.is_error()) GUI::MessageBox::show(window, DeprecatedString::formatted("Couldn't save file: {}.", result.release_error()), "Saving backtrace failed"sv, GUI::MessageBox::Type::Error); }; save_backtrace_button.set_enabled(false); -- cgit v1.2.3