]> granicus.if.org Git - neomutt/commitdiff
Prevent segv if open-appending to an mbox fails. (closes #3918)
authorKevin McCarthy <kevin@8t8.us>
Thu, 2 Mar 2017 22:53:20 +0000 (14:53 -0800)
committerKevin McCarthy <kevin@8t8.us>
Thu, 2 Mar 2017 22:53:20 +0000 (14:53 -0800)
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().

mbox.c

diff --git a/mbox.c b/mbox.c
index 74affebc8ead9255a570ea8a7ae852d4bcb6b68a..57d58b70bfdbd732caee2626f6a3c637f809041d 100644 (file)
--- 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 ();