diff --git a/Userland/Applications/HexEditor/HexEditor.cpp b/Userland/Applications/HexEditor/HexEditor.cpp index addf4047fe..9093aa6013 100644 --- a/Userland/Applications/HexEditor/HexEditor.cpp +++ b/Userland/Applications/HexEditor/HexEditor.cpp @@ -116,13 +116,13 @@ void HexEditor::set_selection(size_t position, size_t length) bool HexEditor::save_as(NonnullRefPtr new_file) { if (m_document->type() == HexDocument::Type::File) { - HexDocumentFile* fileDocument = static_cast(m_document.ptr()); - if (!fileDocument->write_to_file(new_file)) + auto& file_document = static_cast(*m_document); + if (!file_document.write_to_file(new_file)) return false; - fileDocument->set_file(new_file); + file_document.set_file(new_file); } else { - HexDocumentMemory* memoryDocument = static_cast(m_document.ptr()); - if (!memoryDocument->write_to_file(new_file)) + auto& memory_document = static_cast(*m_document); + if (!memory_document.write_to_file(new_file)) return false; m_document = make(new_file); }