From 7dd6aa72455ef1f2aacdc28a00d1eaf632d59593 Mon Sep 17 00:00:00 2001 From: Mark Adler Date: Fri, 11 Aug 2023 10:59:03 -0700 Subject: Fix bug when gzungetc() is used immediately after gzopen(). --- gzread.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gzread.c b/gzread.c index 6034a28..4168cbc 100644 --- a/gzread.c +++ b/gzread.c @@ -443,6 +443,10 @@ int ZEXPORT gzungetc(int c, gzFile file) { return -1; state = (gz_statep)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)) -- cgit v1.2.3-55-g6feb