]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Fix bug when gzungetc() is used immediately after gzopen().
authorMark Adler <madler@alumni.caltech.edu>
Mon, 21 Aug 2023 20:48:56 +0000 (13:48 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Thu, 24 Aug 2023 09:22:33 +0000 (11:22 +0200)
gzread.c.in

index 67a21a3e4daca4e8a743c0430d654ea901b7284b..1fc7b370fde38d246c0c99ff9d802bd069502cb3 100644 (file)
@@ -445,6 +445,10 @@ int Z_EXPORT PREFIX(gzungetc)(int c, gzFile file) {
         return -1;
     state = (gz_state *)file;
 
+    /* in case this was just opened, set up the input buffer */
+    if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0)
+        (void)gz_look(state);
+
     /* check that we're reading and that there's no (serious) error */
     if (state->mode != GZ_READ || (state->err != Z_OK && state->err != Z_BUF_ERROR))
         return -1;