From: Mark Adler Date: Sat, 3 Mar 2012 17:28:00 +0000 (-0800) Subject: Fix bug in gzclose_w() when gzwrite() fails to allocate memory. X-Git-Tag: upstream/1.2.8~118 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=53bfe01cea647ef6f6b86edbc51d0fad4640e4a6;p=platform%2Fupstream%2Fzlib.git Fix bug in gzclose_w() when gzwrite() fails to allocate memory. --- diff --git a/gzwrite.c b/gzwrite.c index 6e6d8a2..27cb342 100644 --- a/gzwrite.c +++ b/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)