diff --git a/parser.c b/parser.c index f8a41a57..df79a7ca 100644 --- a/parser.c +++ b/parser.c @@ -2115,7 +2115,10 @@ static int spacePop(xmlParserCtxtPtr ctxt) { xmlSHRINK (ctxt); static void xmlSHRINK (xmlParserCtxtPtr ctxt) { - xmlParserInputShrink(ctxt->input); + /* Don't shrink memory buffers. */ + if ((ctxt->input->buf) && + ((ctxt->input->buf->encoder) || (ctxt->input->buf->readcallback))) + xmlParserInputShrink(ctxt->input); if (*ctxt->input->cur == 0) xmlParserInputGrow(ctxt->input, INPUT_CHUNK); } diff --git a/xmlreader.c b/xmlreader.c index f367641f..f4ce22b1 100644 --- a/xmlreader.c +++ b/xmlreader.c @@ -840,7 +840,7 @@ xmlTextReaderPushData(xmlTextReaderPtr reader) { * Discard the consumed input when needed and possible */ if (reader->mode == XML_TEXTREADER_MODE_INTERACTIVE) { - if (alloc != XML_BUFFER_ALLOC_IMMUTABLE) { + if (reader->input->readcallback != NULL) { if ((reader->cur >= 4096) && (xmlBufUse(inbuf) - reader->cur <= CHUNK_SIZE)) { val = xmlBufShrink(inbuf, reader->cur);