From: Mark Adler Date: Mon, 21 Aug 2023 20:48:56 +0000 (-0700) Subject: Fix bug when gzungetc() is used immediately after gzopen(). X-Git-Tag: 2.1.4~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=135cdad8ca64ec38407fcd3515515574f2015dcf;p=thirdparty%2Fzlib-ng.git Fix bug when gzungetc() is used immediately after gzopen(). --- diff --git a/gzread.c.in b/gzread.c.in index 67a21a3e4..1fc7b370f 100644 --- a/gzread.c.in +++ b/gzread.c.in @@ -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;