Commit 6a02e87 for zlib

commit 6a02e876fa20b0b2bb12d2c9ab8fc069d786de09
Author: M0nd0R <150439604+M0nd0R@users.noreply.github.com>
Date:   Mon Oct 5 15:44:10 2026 +0000

    Consume pending output in gz_skip before returning a fetch error.

    gz_skip() returned -1 as soon as gz_fetch() failed, even when that fetch
    had just left decompressed output in the output buffer while the skip
    request was still pending. The next gzgetc() then served bytes from
    before the seek target through its fast path (zlib.h macro and the
    equivalent case in gzread.c), which assume that x.have > 0 implies the
    data is at the current position.

    Consume the pending output against the remaining skip before returning
    the error, mirroring the existing gz_read() logic that keeps the same
    invariant for its own fetch path. Reaching data later on a non-blocking
    input source then resumes at the correct position.

diff --git a/gzread.c b/gzread.c
index 5b3e0a5..b63873d 100644
--- a/gzread.c
+++ b/gzread.c
@@ -315,8 +315,12 @@ local int gz_skip(gz_statep state) {

         /* need more data to skip -- load up output buffer */
         else {
-            /* get more output, looking for header if required */
-            if (gz_fetch(state) == -1)
+            /* get more output, looking for header if required. If the fetch
+               stalled but provided some output, consume it before returning
+               so that x.have > 0 always implies the data is at the current
+               logical position (x.pos), as assumed by the gzgetc() fast path
+               in zlib.h and gzread.c */
+            if (gz_fetch(state) == -1 && state->x.have == 0)
                 return -1;
         }
     } while (state->skip);