diff options
| author | David Bremner <david@tethera.net> | 2020-04-12 20:00:31 -0300 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2020-04-13 17:13:55 -0300 |
| commit | 2c1f783f5f4ad28d89f2e83d7253bae7bba98440 (patch) | |
| tree | 625c4cec17dbfe044c0bc78c8c96adf6221d63bb | |
| parent | d50f41c0fd0bbd2ca2b364f49deaea8be63dff3c (diff) | |
don't pass NULL as second parameter to gzerror
Although (as of 1.2.11) zlib checks this parameter before writing to
it, the docs don't promise to keep doing so, so be safe.
| -rw-r--r-- | notmuch-dump.c | 6 | ||||
| -rw-r--r-- | notmuch-restore.c | 2 | ||||
| -rw-r--r-- | util/zlib-extra.c | 2 | ||||
| -rw-r--r-- | util/zlib-extra.h | 5 |
4 files changed, 10 insertions, 5 deletions
diff --git a/notmuch-dump.c b/notmuch-dump.c index 65e02639..af346ba2 100644 --- a/notmuch-dump.c +++ b/notmuch-dump.c @@ -21,7 +21,7 @@ #include "notmuch-client.h" #include "hex-escape.h" #include "string-util.h" -#include <zlib.h> +#include "zlib-extra.h" static int database_dump_config (notmuch_database_t *notmuch, gzFile output) @@ -316,7 +316,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_str (output)); goto DONE; } @@ -332,7 +332,7 @@ notmuch_database_dump (notmuch_database_t *notmuch, ret = gzclose_w (output); if (ret) { fprintf (stderr, "Error closing %s: %s\n", name_for_error, - gzerror (output, NULL)); + gzerror_str (output)); ret = EXIT_FAILURE; output = NULL; goto DONE; diff --git a/notmuch-restore.c b/notmuch-restore.c index 4b509d95..9a8b7fb5 100644 --- a/notmuch-restore.c +++ b/notmuch-restore.c @@ -450,7 +450,7 @@ notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[]) if (input && gzclose_r (input)) { fprintf (stderr, "Error closing %s: %s\n", - name_for_error, gzerror (input, NULL)); + name_for_error, gzerror_str (input)); ret = EXIT_FAILURE; } diff --git a/util/zlib-extra.c b/util/zlib-extra.c index f691cccf..623f6d62 100644 --- a/util/zlib-extra.c +++ b/util/zlib-extra.c @@ -80,7 +80,7 @@ const char * gz_error_string (util_status_t status, gzFile file) { if (status == UTIL_GZERROR) - return gzerror (file, NULL); + return gzerror_str (file); else return util_error_string (status); } diff --git a/util/zlib-extra.h b/util/zlib-extra.h index 209fa998..296dc914 100644 --- a/util/zlib-extra.h +++ b/util/zlib-extra.h @@ -27,6 +27,11 @@ gz_getline (void *ctx, char **lineptr, ssize_t *bytes_read, gzFile stream); const char * gz_error_string (util_status_t status, gzFile stream); +/* Call gzerror with a dummy errno argument, the docs don't promise to + * support the NULL case */ +inline const char * +gzerror_str(gzFile file) { int dummy; return gzerror (file, &dummy); } + #ifdef __cplusplus } #endif |
