summaryrefslogtreecommitdiff
path: root/parserInternals.c
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2023-03-21 13:08:44 +0100
committerNick Wellnhofer <wellnhofer@aevum.de>2023-03-21 13:19:18 +0100
commit04d1bedd8c3fc5d9e41d11e2d0da08a966b732d3 (patch)
tree52ebf8de427a987a058f35a7b54d95992e84539b /parserInternals.c
parent44ecefc8cc299a66ac21ffec141eb261e92638da (diff)
downloadlibxml2-04d1bedd8c3fc5d9e41d11e2d0da08a966b732d3.tar.gz
parser: Rework shrinking of input buffers
Don't try to grow the input buffer in xmlParserShrink. This makes sure that no memory allocations are made and the function always succeeds. Remove unnecessary invocations of SHRINK. Invoke SHRINK at the end of DTD parsing loops. Shrink before growing.
Diffstat (limited to 'parserInternals.c')
-rw-r--r--parserInternals.c16
1 files changed, 2 insertions, 14 deletions
diff --git a/parserInternals.c b/parserInternals.c
index dd165790..ce4f75e0 100644
--- a/parserInternals.c
+++ b/parserInternals.c
@@ -409,17 +409,16 @@ xmlParserInputGrow(xmlParserInputPtr in, int len) {
* xmlParserShrink:
* @ctxt: an XML parser context
*/
-int
+void
xmlParserShrink(xmlParserCtxtPtr ctxt) {
xmlParserInputPtr in = ctxt->input;
xmlParserInputBufferPtr buf = in->buf;
size_t used;
- int ret = 0;
/* Don't shrink memory buffers. */
if ((buf == NULL) ||
((buf->encoder == NULL) && (buf->readcallback == NULL)))
- return(0);
+ return;
used = in->cur - in->base;
/*
@@ -439,18 +438,7 @@ xmlParserShrink(xmlParserCtxtPtr ctxt) {
}
}
- if (xmlBufUse(buf->buffer) < INPUT_CHUNK)
- ret = xmlParserInputBufferGrow(buf, INPUT_CHUNK);
-
xmlBufSetInputBaseCur(buf->buffer, in, 0, used);
-
- /* TODO: Get error code from xmlParserInputBufferGrow */
- if (ret < 0) {
- xmlErrInternal(ctxt, "Growing input buffer", NULL);
- xmlHaltParser(ctxt);
- }
-
- return(ret);
}
/**