1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-26 00:37:43 +03:00

io: Don't shrink memory input buffers

This commit is contained in:
Nick Wellnhofer
2022-11-14 20:16:22 +01:00
parent 117bab2256
commit 4955e0c9e1
2 changed files with 5 additions and 2 deletions

View File

@@ -2115,7 +2115,10 @@ static int spacePop(xmlParserCtxtPtr ctxt) {
xmlSHRINK (ctxt); xmlSHRINK (ctxt);
static void xmlSHRINK (xmlParserCtxtPtr 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) if (*ctxt->input->cur == 0)
xmlParserInputGrow(ctxt->input, INPUT_CHUNK); xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
} }

View File

@@ -840,7 +840,7 @@ xmlTextReaderPushData(xmlTextReaderPtr reader) {
* Discard the consumed input when needed and possible * Discard the consumed input when needed and possible
*/ */
if (reader->mode == XML_TEXTREADER_MODE_INTERACTIVE) { if (reader->mode == XML_TEXTREADER_MODE_INTERACTIVE) {
if (alloc != XML_BUFFER_ALLOC_IMMUTABLE) { if (reader->input->readcallback != NULL) {
if ((reader->cur >= 4096) && if ((reader->cur >= 4096) &&
(xmlBufUse(inbuf) - reader->cur <= CHUNK_SIZE)) { (xmlBufUse(inbuf) - reader->cur <= CHUNK_SIZE)) {
val = xmlBufShrink(inbuf, reader->cur); val = xmlBufShrink(inbuf, reader->cur);