]> git.lizzy.rs Git - zlib.git/commitdiff
Fix bug in gzgets() for a concatenated empty gzip stream.
authorMark Adler <madler@alumni.caltech.edu>
Sat, 24 Sep 2011 07:29:46 +0000 (00:29 -0700)
committerMark Adler <madler@alumni.caltech.edu>
Sat, 24 Sep 2011 07:29:46 +0000 (00:29 -0700)
gzread.c

index d44f2f70a5e632e6864140f35ba5d0d781db7918..695d01d9f085d61016ff0996d0e1aac5533d6a04 100644 (file)
--- a/gzread.c
+++ b/gzread.c
@@ -569,14 +569,14 @@ char * ZEXPORT gzgets(file, buf, len)
     left = (unsigned)len - 1;
     if (left) do {
         /* assure that something is in the output buffer */
-        if (state->have == 0) {
+        while (state->have == 0 && (state->strm.avail_in || !state->eof)) {
             if (gz_make(state) == -1)
                 return NULL;            /* error */
-            if (state->have == 0) {     /* end of file */
-                if (buf == str)         /* got bupkus */
-                    return NULL;
-                break;                  /* got something -- return it */
-            }
+        }
+        if (state->have == 0) {         /* end of file */
+            if (buf == str)             /* got bupkus */
+                return NULL;
+            break;                      /* got something -- return it */
         }
 
         /* look for end-of-line in current output buffer */