Fix bug in gzclose() when gzwrite() runs out of memory.
If the deflateInit2() called for the first gzwrite() failed with a Z_MEM_ERROR, then a subsequent gzclose() would try to free an already freed pointer. This fixes that.
This commit is contained in:
parent
0cf495a1ca
commit
c4888637ea
@ -556,12 +556,13 @@ int ZEXPORT gzclose_w(file)
|
|||||||
/* flush, free memory, and close file */
|
/* flush, free memory, and close file */
|
||||||
if (gz_comp(state, Z_FINISH) == -1)
|
if (gz_comp(state, Z_FINISH) == -1)
|
||||||
ret = state->err;
|
ret = state->err;
|
||||||
|
if (state->size) {
|
||||||
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