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: mutt-1-8-1-rel~10 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=786aa6cf32f8ad76a415b8418c0704c8ee65f676;p=mutt 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 74affebc..57d58b70 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 ();