mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-21 18:38:08 +01:00
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.
This commit is contained in:
parent
d50f41c0fd
commit
2c1f783f5f
4 changed files with 10 additions and 5 deletions
|
@ -21,7 +21,7 @@
|
||||||
#include "notmuch-client.h"
|
#include "notmuch-client.h"
|
||||||
#include "hex-escape.h"
|
#include "hex-escape.h"
|
||||||
#include "string-util.h"
|
#include "string-util.h"
|
||||||
#include <zlib.h>
|
#include "zlib-extra.h"
|
||||||
|
|
||||||
static int
|
static int
|
||||||
database_dump_config (notmuch_database_t *notmuch, gzFile output)
|
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);
|
ret = gzflush (output, Z_FINISH);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
fprintf (stderr, "Error flushing output: %s\n", gzerror (output, NULL));
|
fprintf (stderr, "Error flushing output: %s\n", gzerror_str (output));
|
||||||
goto DONE;
|
goto DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,7 +332,7 @@ notmuch_database_dump (notmuch_database_t *notmuch,
|
||||||
ret = gzclose_w (output);
|
ret = gzclose_w (output);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
fprintf (stderr, "Error closing %s: %s\n", name_for_error,
|
fprintf (stderr, "Error closing %s: %s\n", name_for_error,
|
||||||
gzerror (output, NULL));
|
gzerror_str (output));
|
||||||
ret = EXIT_FAILURE;
|
ret = EXIT_FAILURE;
|
||||||
output = NULL;
|
output = NULL;
|
||||||
goto DONE;
|
goto DONE;
|
||||||
|
|
|
@ -450,7 +450,7 @@ notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[])
|
||||||
|
|
||||||
if (input && gzclose_r (input)) {
|
if (input && gzclose_r (input)) {
|
||||||
fprintf (stderr, "Error closing %s: %s\n",
|
fprintf (stderr, "Error closing %s: %s\n",
|
||||||
name_for_error, gzerror (input, NULL));
|
name_for_error, gzerror_str (input));
|
||||||
ret = EXIT_FAILURE;
|
ret = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ const char *
|
||||||
gz_error_string (util_status_t status, gzFile file)
|
gz_error_string (util_status_t status, gzFile file)
|
||||||
{
|
{
|
||||||
if (status == UTIL_GZERROR)
|
if (status == UTIL_GZERROR)
|
||||||
return gzerror (file, NULL);
|
return gzerror_str (file);
|
||||||
else
|
else
|
||||||
return util_error_string (status);
|
return util_error_string (status);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,11 @@ gz_getline (void *ctx, char **lineptr, ssize_t *bytes_read, gzFile stream);
|
||||||
const char *
|
const char *
|
||||||
gz_error_string (util_status_t status, gzFile stream);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue