From: Kevin McCarthy Date: Thu, 2 Mar 2017 22:53:20 +0000 (-0800) Subject: Prevent segv if open-appending to an mbox fails. (closes #3918) X-Git-Tag: neomutt-20170306~2^2~2^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=da2cc1701e0d4e93cd82fa2fc945efe60e6e29f4;p=neomutt Prevent segv if open-appending to an mbox fails. (closes #3918) If mbox_open_mailbox_append() fails, ctx->fp will be null. Add a check in mbox_close_mailbox(), to prevent a segv from passing null to fileno(). --- diff --git a/mbox.c b/mbox.c index 74affebc8..57d58b70b 100644 --- a/mbox.c +++ b/mbox.c @@ -465,7 +465,7 @@ static int mbox_open_mailbox_append (CONTEXT *ctx, int flags) static int mbox_close_mailbox (CONTEXT *ctx) { - if (ctx->append) + if (ctx->append && ctx->fp) { mx_unlock_file (ctx->path, fileno (ctx->fp), 1); mutt_unblock_signals ();