diff options
-rw-r--r-- | gzwrite.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -554,15 +554,14 @@ int ZEXPORT gzclose_w(file) | |||
554 | } | 554 | } |
555 | 555 | ||
556 | /* flush, free memory, and close file */ | 556 | /* flush, free memory, and close file */ |
557 | if (state->size) { | 557 | if (gz_comp(state, Z_FINISH) == -1) |
558 | if (gz_comp(state, Z_FINISH) == -1) | 558 | ret = state->err; |
559 | ret = state->err; | 559 | if (!state->direct) { |
560 | if (!state->direct) { | 560 | (void)deflateEnd(&(state->strm)); |
561 | (void)deflateEnd(&(state->strm)); | 561 | free(state->out); |
562 | free(state->out); | ||
563 | } | ||
564 | free(state->in); | ||
565 | } | 562 | } |
563 | if (state->size) | ||
564 | free(state->in); | ||
566 | gz_error(state, Z_OK, NULL); | 565 | gz_error(state, Z_OK, NULL); |
567 | free(state->path); | 566 | free(state->path); |
568 | if (close(state->fd) == -1) | 567 | if (close(state->fd) == -1) |