Prevent a crash when reopening a Mailbox.
> How exactly do these changes prevent the crash from occurring?
It's all about how mx_mbox_open() handles flags. These four examples
are where we have a Mailbox open in 'normal' mode and try to open it
again in 'append' mode.
'Append' mode only makes sense for 'mbox' and 'compress', but the flag
affects mx_mbox_open(). It causes the function to create a duplicate
Mailbox, which is then used and discarded. The original Mailbox is now
out of sync.
The workaround, simply hides the flag for mx_mbox_open(), but
temporarily sets the internal bool append. This means that we work with
one Mailbox.
}
struct Mailbox *m_spool = mx_path_resolve(C_Spoolfile);
- struct Context *ctx = mx_mbox_open(m_spool, MUTT_APPEND);
+ struct Context *ctx = mx_mbox_open(m_spool, MUTT_OPEN_NO_FLAGS);
if (!ctx)
{
mailbox_free(&m_spool);
goto finish;
}
+ bool old_append = m_spool->append;
+ m_spool->append = true;
+
enum QuadOption delanswer =
query_quadoption(C_PopDelete, _("Delete messages from server?"));
if (ret == -1)
{
+ m_spool->append = old_append;
mx_mbox_close(&ctx);
goto fail;
}
msgbuf, i - last, msgs - last);
}
+ m_spool->append = old_append;
mx_mbox_close(&ctx);
if (rset)