diff options
-rw-r--r-- | gzwrite.c | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -547,13 +547,15 @@ int ZEXPORT gzclose_w(file) | |||
547 | } | 547 | } |
548 | 548 | ||
549 | /* flush, free memory, and close file */ | 549 | /* flush, free memory, and close file */ |
550 | if (gz_comp(state, Z_FINISH) == -1) | 550 | if (state->size) { |
551 | ret = state->err; | 551 | if (gz_comp(state, Z_FINISH) == -1) |
552 | if (!state->direct) { | 552 | ret = state->err; |
553 | (void)deflateEnd(&(state->strm)); | 553 | if (!state->direct) { |
554 | free(state->out); | 554 | (void)deflateEnd(&(state->strm)); |
555 | free(state->out); | ||
556 | } | ||
557 | free(state->in); | ||
555 | } | 558 | } |
556 | free(state->in); | ||
557 | gz_error(state, Z_OK, NULL); | 559 | gz_error(state, Z_OK, NULL); |
558 | free(state->path); | 560 | free(state->path); |
559 | if (close(state->fd) == -1) | 561 | if (close(state->fd) == -1) |