Commit 6ed77c4 for zlib
commit 6ed77c4885c7df5e3b118171018177c009512c3a
Author: Mark Adler <git@madler.net>
Date: Sun Sep 20 18:01:14 2026 -0700
Leave the stream position unchanged when gzseek() fails.
diff --git a/gzlib.c b/gzlib.c
index 0a928be..a85e99e 100644
--- a/gzlib.c
+++ b/gzlib.c
@@ -389,8 +389,6 @@ z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) {
state->x.pos + (state->past ? 0 : state->skip);
if (offset > GZ_OFF_MAX - pos)
return -1; /* would overflow z_off64_t */
- if (whence != SEEK_SET)
- state->skip = 0;
if (offset < -pos)
return -1; /* before start of file */
pos += offset;
diff --git a/zlib.h b/zlib.h
index c104b14..ff137fc 100644
--- a/zlib.h
+++ b/zlib.h
@@ -1678,7 +1678,8 @@ ZEXTERN z_off_t ZEXPORT gzseek(gzFile file,
the beginning of the uncompressed stream, or -1 in case of error, in
particular if the file is opened for writing and the new starting position
would be before the current position, or if the resulting position would
- not be representable in the offset type.
+ not be representable in the offset type. If gzseek returns -1, the stream
+ position is unchanged.
*/
ZEXTERN int ZEXPORT gzrewind(gzFile file);