diff options
| author | Mark Adler <madler@alumni.caltech.edu> | 2011-09-30 22:19:12 -0700 |
|---|---|---|
| committer | Mark Adler <madler@alumni.caltech.edu> | 2011-09-30 22:19:12 -0700 |
| commit | 8768ba98af1cf44e9a24fa7dbdf013de4afecf62 (patch) | |
| tree | 9391179a68d627b86802b5ef4d6a2d7d4c029204 /gzwrite.c | |
| parent | acfc85772a811f4c0efec835a3087b53f83f6079 (diff) | |
| download | Project-Tick-8768ba98af1cf44e9a24fa7dbdf013de4afecf62.tar.gz Project-Tick-8768ba98af1cf44e9a24fa7dbdf013de4afecf62.zip | |
Fix gzclose() to return the actual error last encountered.
Diffstat (limited to 'gzwrite.c')
| -rw-r--r-- | gzwrite.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -504,7 +504,7 @@ int ZEXPORT gzsetparams(file, level, strategy) int ZEXPORT gzclose_w(file) gzFile file; { - int ret = 0; + int ret = Z_OK; gz_statep state; /* get internal structure */ @@ -519,17 +519,20 @@ int ZEXPORT gzclose_w(file) /* check for seek request */ if (state->seek) { state->seek = 0; - ret += gz_zero(state, state->skip); + if (gz_zero(state, state->skip) == -1) + ret = state->err; } /* flush, free memory, and close file */ - ret += gz_comp(state, Z_FINISH); + if (gz_comp(state, Z_FINISH) == -1) + ret = state->err; (void)deflateEnd(&(state->strm)); free(state->out); free(state->in); gz_error(state, Z_OK, NULL); free(state->path); - ret += close(state->fd); + if (close(state->fd) == -1) + ret = Z_ERRNO; free(state); - return ret ? Z_ERRNO : Z_OK; + return ret; } |
