1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:47:46 +00:00

Mail: Fix crash when closing window before IMAP::Client connects

`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.
This commit is contained in:
Valtteri Koskivuori 2023-07-25 21:04:23 +03:00 committed by Andrew Kaster
parent 055d2b6c8a
commit 08fb98caac

View file

@ -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);