Skip to content

Commit

Permalink
Fix bug when gzungetc() is used immediately after gzopen().
Browse files Browse the repository at this point in the history
  • Loading branch information
madler authored and Dead2 committed Aug 24, 2023
1 parent faf6cf7 commit 135cdad
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gzread.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 135cdad

Please sign in to comment.