38d10a
From 41beb477c5744bc396fa1162ee0c14218ec12213 Mon Sep 17 00:00:00 2001
38d10a
From: Mark Adler <madler@alumni.caltech.edu>
38d10a
Date: Mon, 27 May 2019 08:20:32 -0700
38d10a
Subject: [PATCH] Fix bug in undefer_input() that misplaced the input state.
38d10a
38d10a
---
38d10a
 fileio.c | 4 +++-
38d10a
 1 file changed, 3 insertions(+), 1 deletion(-)
38d10a
38d10a
diff --git a/fileio.c b/fileio.c
38d10a
index c042987..bc00d74 100644
38d10a
--- a/fileio.c
38d10a
+++ b/fileio.c
38d10a
@@ -530,8 +530,10 @@ void undefer_input(__G)
38d10a
          * This condition was checked when G.incnt_leftover was set > 0 in
38d10a
          * defer_leftover_input(), and it is NOT allowed to touch G.csize
38d10a
          * before calling undefer_input() when (G.incnt_leftover > 0)
38d10a
-         * (single exception: see read_byte()'s  "G.csize <= 0" handling) !!
38d10a
+         * (single exception: see readbyte()'s  "G.csize <= 0" handling) !!
38d10a
          */
38d10a
+        if (G.csize < 0L)
38d10a
+            G.csize = 0L;
38d10a
         G.incnt = G.incnt_leftover + (int)G.csize;
38d10a
         G.inptr = G.inptr_leftover - (int)G.csize;
38d10a
         G.incnt_leftover = 0;