Skip to content

Commit

Permalink
Mail: Fix crash when closing window before IMAP::Client connects
Browse files Browse the repository at this point in the history
`MailWidget::m_imap_client` is only assigned after a connection is
established, so the user might close the main window before that
happens, especially if the connection hangs for whatever reason.
Now we check the `OwnPtr` before working with it.
  • Loading branch information
vkoskiv authored and ADKaster committed Aug 12, 2023
1 parent 055d2b6 commit 08fb98c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Userland/Applications/Mail/MailWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ bool MailWidget::connect_and_login()

void MailWidget::on_window_close()
{
if (!m_imap_client) {
// User closed main window before a connection was established
return;
}
auto response = move(MUST(m_imap_client->send_simple_command(IMAP::CommandType::Logout)->await()).release_value().get<IMAP::SolidResponse>());
VERIFY(response.status() == IMAP::ResponseStatus::OK);

Expand Down

0 comments on commit 08fb98c

Please sign in to comment.