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.
char buf[256];
int rc;
struct stat sb;
+ bool old_append = m->append;
mutt_mktemp(fname, sizeof(fname));
goto bail;
}
- struct Context *ctx_app = mx_mbox_open(m, MUTT_APPEND);
+ struct Context *ctx_app = mx_mbox_open(m, MUTT_OPEN_NO_FLAGS);
if (!ctx_app)
{
rc = -1;
goto bail;
}
+ old_append = m->append;
+ m->append = true;
+
MsgOpenFlags of = MUTT_MSG_NO_FLAGS;
CopyHeaderFlags cf =
(((ctx_app->mailbox->magic == MUTT_MBOX) || (ctx_app->mailbox->magic == MUTT_MMDF)) ?
else if (rc == -1)
mutt_message(_("Error. Preserving temporary file: %s"), fname);
+ m->append = old_append;
return rc;
}