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