diff options
| author | Mark Adler <madler@alumni.caltech.edu> | 2012-03-03 09:28:00 -0800 |
|---|---|---|
| committer | Mark Adler <madler@alumni.caltech.edu> | 2012-03-03 09:28:00 -0800 |
| commit | 53bfe01cea647ef6f6b86edbc51d0fad4640e4a6 (patch) | |
| tree | 1db515a64055420ade64ec046c24d3fb2fc22671 | |
| parent | dab7531eccdb5b22368797ae7958471401d1e427 (diff) | |
| download | zlib-53bfe01cea647ef6f6b86edbc51d0fad4640e4a6.tar.gz zlib-53bfe01cea647ef6f6b86edbc51d0fad4640e4a6.tar.bz2 zlib-53bfe01cea647ef6f6b86edbc51d0fad4640e4a6.zip | |
Fix bug in gzclose_w() when gzwrite() fails to allocate memory.
| -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) |
