On some operating systems, close() can be interrupted by a signal.
Thus to close a file and report an error on failure, portable
applications have to do something like this:

 while (close(fd) < 0)
        if (errno != EINTR) {
                perror("close");
                exit(1);
        }

Allow applications to do the same with zlib:

 for (;;) {
        int err;
        const char *errmsg;

        err = gzclose(gzfile);
        if (err == Z_ERRNO && errno == EINTR) continue;
        if (!err)
                break;

        errmsg = err == Z_ERRNO ? strerror(errno) : zError(err);
        fprintf(stderr, "gzclose: %s\n", errmsg);
        exit(1);
 }
---
Jonathan Nieder wrote:
> Jonathan Nieder wrote:

>> gzclose_r (does not report I/O errors!)
> 
> Here’s half of the fix to that.

Here is the other half (also untested).

 gzread.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/gzread.c b/gzread.c
index 5603eca..7ba3268 100644
--- a/gzread.c
+++ b/gzread.c
@@ -622,10 +622,12 @@ int ZEXPORT gzclose_r(file)
         inflateEnd(&(state->strm));
         free(state->out);
         free(state->in);
+        state->size = 0;
     }
     gz_error(state, Z_OK, NULL);
     if (close(state->fd)) {
-        free(state);
+        if (errno != EINTR)
+            free(state);
         return -1;
     }
     return Z_OK;



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to