diff options
-rw-r--r-- | gzwrite.c | 13 | ||||
-rw-r--r-- | zlib.h | 2 |
2 files changed, 9 insertions, 6 deletions
@@ -504,7 +504,7 @@ int ZEXPORT gzsetparams(file, level, strategy) | |||
504 | int ZEXPORT gzclose_w(file) | 504 | int ZEXPORT gzclose_w(file) |
505 | gzFile file; | 505 | gzFile file; |
506 | { | 506 | { |
507 | int ret = 0; | 507 | int ret = Z_OK; |
508 | gz_statep state; | 508 | gz_statep state; |
509 | 509 | ||
510 | /* get internal structure */ | 510 | /* get internal structure */ |
@@ -519,17 +519,20 @@ int ZEXPORT gzclose_w(file) | |||
519 | /* check for seek request */ | 519 | /* check for seek request */ |
520 | if (state->seek) { | 520 | if (state->seek) { |
521 | state->seek = 0; | 521 | state->seek = 0; |
522 | ret += gz_zero(state, state->skip); | 522 | if (gz_zero(state, state->skip) == -1) |
523 | ret = state->err; | ||
523 | } | 524 | } |
524 | 525 | ||
525 | /* flush, free memory, and close file */ | 526 | /* flush, free memory, and close file */ |
526 | ret += gz_comp(state, Z_FINISH); | 527 | if (gz_comp(state, Z_FINISH) == -1) |
528 | ret = state->err; | ||
527 | (void)deflateEnd(&(state->strm)); | 529 | (void)deflateEnd(&(state->strm)); |
528 | free(state->out); | 530 | free(state->out); |
529 | free(state->in); | 531 | free(state->in); |
530 | gz_error(state, Z_OK, NULL); | 532 | gz_error(state, Z_OK, NULL); |
531 | free(state->path); | 533 | free(state->path); |
532 | ret += close(state->fd); | 534 | if (close(state->fd) == -1) |
535 | ret = Z_ERRNO; | ||
533 | free(state); | 536 | free(state); |
534 | return ret ? Z_ERRNO : Z_OK; | 537 | return ret; |
535 | } | 538 | } |
@@ -1446,7 +1446,7 @@ ZEXTERN int ZEXPORT gzclose OF((gzFile file)); | |||
1446 | must not be called more than once on the same allocation. | 1446 | must not be called more than once on the same allocation. |
1447 | 1447 | ||
1448 | gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a | 1448 | gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a |
1449 | file operation error, or Z_OK on success. | 1449 | file operation error, Z_MEM_ERROR if out of memory, or Z_OK on success. |
1450 | */ | 1450 | */ |
1451 | 1451 | ||
1452 | ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); | 1452 | ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); |