[PATCH] notmuch-dump.c: Fix output file being closed twice

Subject: [PATCH] notmuch-dump.c: Fix output file being closed twice

Date: Tue, 23 Jul 2019 22:30:02 +0200

To: notmuch@notmuchmail.org

Cc:

From: Ralph Seichter


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 | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

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

_______________________________________________
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch

Thread: