aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gzwrite.c14
1 files changed, 8 insertions, 6 deletions
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)
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)