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

Ralph Seichter abbot at monksofcool.net
Tue Jul 23 13:48:23 PDT 2019


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



More information about the notmuch mailing list