diff --git a/parser.c b/parser.c
index 3b3eae58..14288713 100644
--- a/parser.c
+++ b/parser.c
@@ -2261,13 +2261,11 @@ static int spacePop(xmlParserCtxtPtr ctxt) {
xmlParserGrow(ctxt); \
} while (0)
-#define SHRINK if ((ctxt->progressive == 0) && \
- (ctxt->input->cur - ctxt->input->base > 2 * INPUT_CHUNK) && \
+#define SHRINK if ((ctxt->input->cur - ctxt->input->base > 2 * INPUT_CHUNK) && \
(ctxt->input->end - ctxt->input->cur < 2 * INPUT_CHUNK)) \
xmlParserShrink(ctxt);
-#define GROW if ((ctxt->progressive == 0) && \
- (ctxt->input->end - ctxt->input->cur < INPUT_CHUNK)) \
+#define GROW if (ctxt->input->end - ctxt->input->cur < INPUT_CHUNK) \
xmlParserGrow(ctxt);
#define SKIP_BLANKS xmlSkipBlankChars(ctxt)
diff --git a/parserInternals.c b/parserInternals.c
index 59011002..9667ccb4 100644
--- a/parserInternals.c
+++ b/parserInternals.c
@@ -519,7 +519,7 @@ xmlParserGrow(xmlParserCtxtPtr ctxt) {
if (buf == NULL)
return(0);
/* Don't grow push parser buffer. */
- if (ctxt->progressive)
+ if ((ctxt->progressive) && (ctxt->inputNr <= 1))
return(0);
if (buf->error != 0)
return(-1);
@@ -603,10 +603,9 @@ xmlParserShrink(xmlParserCtxtPtr ctxt) {
xmlParserInputBufferPtr buf = in->buf;
size_t used;
- /* Don't shrink pull parser memory buffers. */
+ /* Don't shrink push parser buffer. */
if ((buf == NULL) ||
- ((ctxt->progressive == 0) &&
- (buf->encoder == NULL) && (buf->readcallback == NULL)))
+ ((ctxt->progressive) && (ctxt->inputNr <= 1)))
return;
used = in->cur - in->base;
diff --git a/result/valid/huge.xml b/result/valid/huge.xml
new file mode 100644
index 00000000..648c1b9d
--- /dev/null
+++ b/result/valid/huge.xml
@@ -0,0 +1,6 @@
+
+
+
+]>
+test
diff --git a/result/valid/pe-latin1.xml b/result/valid/pe-latin1.xml
new file mode 100644
index 00000000..00148999
--- /dev/null
+++ b/result/valid/pe-latin1.xml
@@ -0,0 +1,7 @@
+
+
+
+
+]>
+&latin1;
diff --git a/test/valid/dtds/huge.ent b/test/valid/dtds/huge.ent
new file mode 100644
index 00000000..2915fed3
--- /dev/null
+++ b/test/valid/dtds/huge.ent
@@ -0,0 +1,104 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/valid/dtds/pe-latin1.ent b/test/valid/dtds/pe-latin1.ent
new file mode 100644
index 00000000..cfee482f
--- /dev/null
+++ b/test/valid/dtds/pe-latin1.ent
@@ -0,0 +1,2 @@
+
+
diff --git a/test/valid/huge.xml b/test/valid/huge.xml
new file mode 100644
index 00000000..7aed38c4
--- /dev/null
+++ b/test/valid/huge.xml
@@ -0,0 +1,5 @@
+
+%pe;
+]>
+test
diff --git a/test/valid/pe-latin1.xml b/test/valid/pe-latin1.xml
new file mode 100644
index 00000000..33bd9102
--- /dev/null
+++ b/test/valid/pe-latin1.xml
@@ -0,0 +1,6 @@
+
+
+%pe;
+]>
+&latin1;