1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-24 13:33:01 +03:00

parser: Stop calling xmlParserInputShrink

Introduce xmlParserShrink which takes a parser context to simplify error
handling.
This commit is contained in:
Nick Wellnhofer
2023-03-13 17:51:13 +01:00
parent 483793940c
commit 2099441f32
4 changed files with 62 additions and 12 deletions

View File

@@ -2065,16 +2065,7 @@ static int spacePop(xmlParserCtxtPtr ctxt) {
#define SHRINK if ((ctxt->progressive == 0) && \
(ctxt->input->cur - ctxt->input->base > 2 * INPUT_CHUNK) && \
(ctxt->input->end - ctxt->input->cur < 2 * INPUT_CHUNK)) \
xmlSHRINK (ctxt);
static void xmlSHRINK (xmlParserCtxtPtr ctxt) {
/* 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)
xmlParserGrow(ctxt);
}
xmlParserShrink(ctxt);
#define GROW if ((ctxt->progressive == 0) && \
(ctxt->input->end - ctxt->input->cur < INPUT_CHUNK)) \
@@ -11484,7 +11475,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
if ((ctxt->input != NULL) &&
(ctxt->input->cur - ctxt->input->base > 4096)) {
xmlParserInputShrink(ctxt->input);
xmlParserShrink(ctxt);
}
while (ctxt->instate != XML_PARSER_EOF) {