$OpenBSD$

Our gzerror(3) expects it's errnum argument to be non-NULL.

zlib's gzclose_w() was introduced in 1.2.3.5 from 08.01.2010, we ship
1.2.3 from 18.07.2005.

Index: notmuch-dump.c
--- notmuch-dump.c.orig
+++ notmuch-dump.c
@@ -288,6 +288,8 @@ notmuch_database_dump (notmuch_database_t *notmuch,
 
     int ret = -1;
 
+    int errnum;
+
     if (output_file_name) {
 	tempname = talloc_asprintf (notmuch, "%s.XXXXXX", output_file_name);
 	outfd = mkstemp (tempname);
@@ -316,7 +318,7 @@ notmuch_database_dump (notmuch_database_t *notmuch,
 
     ret = gzflush (output, Z_FINISH);
     if (ret) {
-	fprintf (stderr, "Error flushing output: %s\n", gzerror (output, NULL));
+	fprintf (stderr, "Error flushing output: %s\n", gzerror (output, &errnum));
 	goto DONE;
     }
 
@@ -329,9 +331,9 @@ notmuch_database_dump (notmuch_database_t *notmuch,
 	}
     }
 
-    if (gzclose_w (output) != Z_OK) {
+    if (gzclose (output) != Z_OK) {
 	fprintf (stderr, "Error closing %s: %s\n", name_for_error,
-		 gzerror (output, NULL));
+		 gzerror (output, &errnum));
 	ret = EXIT_FAILURE;
 	output = NULL;
 	goto DONE;
@@ -348,7 +350,7 @@ notmuch_database_dump (notmuch_database_t *notmuch,
     }
  DONE:
     if (ret != EXIT_SUCCESS && output)
-	(void) gzclose_w (output);
+	(void) gzclose (output);
 
     if (ret != EXIT_SUCCESS && output_file_name)
 	(void) unlink (tempname);
