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.
This commit is contained in:
parent
bd143f1c0a
commit
0cf495a1ca
@ -554,15 +554,14 @@ int ZEXPORT gzclose_w(file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* flush, free memory, and close file */
|
/* flush, free memory, and close file */
|
||||||
if (state->size) {
|
|
||||||
if (gz_comp(state, Z_FINISH) == -1)
|
if (gz_comp(state, Z_FINISH) == -1)
|
||||||
ret = state->err;
|
ret = state->err;
|
||||||
if (!state->direct) {
|
if (!state->direct) {
|
||||||
(void)deflateEnd(&(state->strm));
|
(void)deflateEnd(&(state->strm));
|
||||||
free(state->out);
|
free(state->out);
|
||||||
}
|
}
|
||||||
|
if (state->size)
|
||||||
free(state->in);
|
free(state->in);
|
||||||
}
|
|
||||||
gz_error(state, Z_OK, NULL);
|
gz_error(state, Z_OK, NULL);
|
||||||
free(state->path);
|
free(state->path);
|
||||||
if (close(state->fd) == -1)
|
if (close(state->fd) == -1)
|
||||||
|
Loading…
Reference in New Issue
Block a user