Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix bug in gzclose_w() when gzwrite() fails to allocate memory.

  • Loading branch information...
commit 53bfe01cea647ef6f6b86edbc51d0fad4640e4a6 1 parent dab7531
@madler authored
Showing with 8 additions and 6 deletions.
  1. +8 −6 gzwrite.c
View
14 gzwrite.c
@@ -547,13 +547,15 @@ int ZEXPORT gzclose_w(file)
}
/* flush, free memory, and close file */
- if (gz_comp(state, Z_FINISH) == -1)
- ret = state->err;
- if (!state->direct) {
- (void)deflateEnd(&(state->strm));
- free(state->out);
+ if (state->size) {
+ if (gz_comp(state, Z_FINISH) == -1)
+ ret = state->err;
+ if (!state->direct) {
+ (void)deflateEnd(&(state->strm));
+ free(state->out);
+ }
+ free(state->in);
}
- free(state->in);
gz_error(state, Z_OK, NULL);
free(state->path);
if (close(state->fd) == -1)
Please sign in to comment.
Something went wrong with that request. Please try again.