parser.c: shrink the input buffer when appropriate
Fixes GNOME/libxml2#200
Also see discussions at:
- GNOME/libxml2#192
- https://gitlab.gnome.org/nwellnhof/libxml2/-/commit/99bda1e
- https://github.com/sparklemotion/nokogiri/issues/2132
diff --git a/parser.c b/parser.c
index a7bdc7f..efde672 100644
--- a/parser.c
+++ b/parser.c
@@ -4204,6 +4204,7 @@
}
count++;
if (count > 50) {
+ SHRINK;
GROW;
count = 0;
if (ctxt->instate == XML_PARSER_EOF) {
@@ -4291,6 +4292,7 @@
buf[len++] = cur;
count++;
if (count > 50) {
+ SHRINK;
GROW;
count = 0;
if (ctxt->instate == XML_PARSER_EOF) {
@@ -4571,6 +4573,7 @@
}
count++;
if (count > 50) {
+ SHRINK;
GROW;
count = 0;
if (ctxt->instate == XML_PARSER_EOF)
@@ -4776,6 +4779,7 @@
count++;
if (count > 50) {
+ SHRINK;
GROW;
count = 0;
if (ctxt->instate == XML_PARSER_EOF) {
@@ -5186,6 +5190,7 @@
}
count++;
if (count > 50) {
+ SHRINK;
GROW;
if (ctxt->instate == XML_PARSER_EOF) {
xmlFree(buf);
@@ -9783,6 +9788,7 @@
sl = l;
count++;
if (count > 50) {
+ SHRINK;
GROW;
if (ctxt->instate == XML_PARSER_EOF) {
xmlFree(buf);