diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2021-09-06 03:29:52 +0430 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-06 01:53:26 +0200 |
commit | 97e97bccab085823d1365cb54142fd8c41dbcd8c (patch) | |
tree | 9008687dbcdfb6f36f6dc6372aa382b15b9d36c8 /Userland/Applications/HexEditor/HexEditorWidget.cpp | |
parent | 3a9f00c59bad7735970c72cb940d08161fda09b0 (diff) | |
download | serenity-97e97bccab085823d1365cb54142fd8c41dbcd8c.zip |
Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safe
Diffstat (limited to 'Userland/Applications/HexEditor/HexEditorWidget.cpp')
-rw-r--r-- | Userland/Applications/HexEditor/HexEditorWidget.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Userland/Applications/HexEditor/HexEditorWidget.cpp b/Userland/Applications/HexEditor/HexEditorWidget.cpp index 160980e68c..8c3c7a71da 100644 --- a/Userland/Applications/HexEditor/HexEditorWidget.cpp +++ b/Userland/Applications/HexEditor/HexEditorWidget.cpp @@ -75,7 +75,12 @@ HexEditorWidget::HexEditorWidget() auto file_size = value.to_int(); if (file_size.has_value() && file_size.value() > 0) { m_document_dirty = false; - m_editor->set_buffer(ByteBuffer::create_zeroed(file_size.value())); + auto buffer_result = ByteBuffer::create_zeroed(file_size.value()); + if (!buffer_result.has_value()) { + GUI::MessageBox::show(window(), "Entered file size is too large.", "Error", GUI::MessageBox::Type::Error); + return; + } + m_editor->set_buffer(buffer_result.release_value()); set_path({}); update_title(); } else { |