]> git.notmuchmail.org Git - notmuch/commitdiff
notmuch-dump.c: Fix output file being closed twice
authorRalph Seichter <abbot@monksofcool.net>
Tue, 23 Jul 2019 20:48:23 +0000 (22:48 +0200)
committerDavid Bremner <david@tethera.net>
Wed, 27 Nov 2019 12:00:00 +0000 (08:00 -0400)
Fixed: If the output file for a dump was non-writeable, gzclose_w()
was called twice on the output file handle, resulting in SIGABRT.

(cherry picked from commit 17806ecc955ce0375146ea1df51eae061a72bef8)

notmuch-dump.c

index ef2f02dfeb5cb5cc470da3462f75d6122f488f95..70cdb0c21718f8f0738760a0ed8d3e5a0486f44f 100644 (file)
@@ -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;
        goto DONE;
-    }
+    } else
+        output = NULL;
 
     if (output_file_name) {
        ret = rename (tempname, output_file_name);