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 committed Aug 11, 2023
1 parent c7ddcc2 commit 7dd6aa7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gzread.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 7dd6aa7

Please sign in to comment.