unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Ralph Seichter <abbot@monksofcool.net>
To: notmuch@notmuchmail.org
Subject: [PATCH] notmuch-dump.c: Fix output file being closed twice
Date: Tue, 23 Jul 2019 22:48:23 +0200	[thread overview]
Message-ID: <20190723204823.31665-2-abbot@monksofcool.net> (raw)
In-Reply-To: <20190723204823.31665-1-abbot@monksofcool.net>

Fixed: If the output file for a dump was non-writeable, gzclose_w()
was called twice on the output file handle, resulting in SIGABRT.
---
 notmuch-dump.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/notmuch-dump.c b/notmuch-dump.c
index 505c1469..ca73d003 100644
--- a/notmuch-dump.c
+++ b/notmuch-dump.c
@@ -329,13 +329,15 @@ notmuch_database_dump (notmuch_database_t *notmuch,
 	}
     }
 
-    if (gzclose_w (output) != Z_OK) {
+    ret = gzclose_w (output);
+    if (ret) {
 	fprintf (stderr, "Error closing %s: %s\n", name_for_error,
 		 gzerror (output, NULL));
 	ret = EXIT_FAILURE;
-	output = NULL;
+        output = NULL;
 	goto DONE;
-    }
+    } else
+        output = NULL;
 
     if (output_file_name) {
 	ret = rename (tempname, output_file_name);
-- 
2.21.0

  reply	other threads:[~2019-07-23 20:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-23 20:30 [PATCH] notmuch-dump.c: Fix output file being closed twice Ralph Seichter
2019-07-23 20:48 ` [PATCH] notmuch-dump.c: Fix output file being closed twice (V2) Ralph Seichter
2019-07-23 20:48   ` Ralph Seichter [this message]
2019-07-23 22:26     ` [PATCH] notmuch-dump.c: Fix output file being closed twice David Bremner
2019-07-24 20:56       ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190723204823.31665-2-abbot@monksofcool.net \
    --to=abbot@monksofcool.net \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).