Fix bug where gzopen(), gzclose() would write an empty file.

A gzopen() to write (mode "w") followed immediately by a gzclose()
would output an empty zero-length file.  What it should do is write
an empty gzip file, with the gzip header, empty deflate content,
and gzip trailer totalling 20 bytes.  This fixes it to do that.
pull/30/head
Mark Adler 12 years ago
parent bd143f1c0a
commit 0cf495a1ca
  1. 3
      gzwrite.c

@ -554,15 +554,14 @@ int ZEXPORT gzclose_w(file)
}
/* flush, free memory, and close file */
if (state->size) {
if (gz_comp(state, Z_FINISH) == -1)
ret = state->err;
if (!state->direct) {
(void)deflateEnd(&(state->strm));
free(state->out);
}
if (state->size)
free(state->in);
}
gz_error(state, Z_OK, NULL);
free(state->path);
if (close(state->fd) == -1)

Loading…
Cancel
Save