]> git.lizzy.rs Git - zlib.git/commitdiff
Avoid use of Z_BUF_ERROR in gz* functions except for premature EOF.
authorMark Adler <madler@alumni.caltech.edu>
Wed, 14 Dec 2011 06:25:59 +0000 (22:25 -0800)
committerMark Adler <madler@alumni.caltech.edu>
Wed, 14 Dec 2011 06:29:37 +0000 (22:29 -0800)
Z_BUF_ERROR was also being used for an unsuccessful gzungetc and for buffer
lengths that didn't fit in an int.  Those uses were changed to Z_DATA_ERROR
in order to assure that Z_BUF_ERROR occurs only when a premature end of
input occurs, indicating that gzclearerr() can be used.

gzread.c
gzwrite.c

index 1e97e38d70e7975bcec86d785fe40b42200c4937..4bbbf52e460e4a9af089962908efca25dba7d72e 100644 (file)
--- a/gzread.c
+++ b/gzread.c
@@ -302,7 +302,7 @@ int ZEXPORT gzread(file, buf, len)
     /* since an int is returned, make sure len fits in one, otherwise return
        with an error (this avoids the flaw in the interface) */
     if ((int)len < 0) {
-        gz_error(state, Z_BUF_ERROR, "requested length does not fit in int");
+        gz_error(state, Z_DATA_ERROR, "requested length does not fit in int");
         return -1;
     }
 
@@ -445,7 +445,7 @@ int ZEXPORT gzungetc(c, file)
 
     /* if no room, give up (must have already done a gzungetc()) */
     if (state->x.have == (state->size << 1)) {
-        gz_error(state, Z_BUF_ERROR, "out of room to push characters");
+        gz_error(state, Z_DATA_ERROR, "out of room to push characters");
         return -1;
     }
 
index 2dcb3fce6b15d69f6f34d87214db756c390a5d2b..18ade4ada8ffff0e5d8f6db2b5d875a4877e75e2 100644 (file)
--- a/gzwrite.c
+++ b/gzwrite.c
@@ -185,7 +185,7 @@ int ZEXPORT gzwrite(file, buf, len)
     /* since an int is returned, make sure len fits in one, otherwise return
        with an error (this avoids the flaw in the interface) */
     if ((int)len < 0) {
-        gz_error(state, Z_BUF_ERROR, "requested length does not fit in int");
+        gz_error(state, Z_DATA_ERROR, "requested length does not fit in int");
         return 0;
     }