Unverified Commit ca565c1e authored by Mike Dalessio's avatar Mike Dalessio
Browse files

parser.c: shrink the input buffer when appropriate

Fixes GNOME/libxml2#200

Also see discussions at:
- GNOME/libxml2#192
- nwellnhof/libxml2@99bda1e1
- https://github.com/sparklemotion/nokogiri/issues/2132
parent f93ca3e1
Pipeline #251742 passed with stage
in 9 minutes and 2 seconds
...@@ -4204,6 +4204,7 @@ xmlParseSystemLiteral(xmlParserCtxtPtr ctxt) { ...@@ -4204,6 +4204,7 @@ xmlParseSystemLiteral(xmlParserCtxtPtr ctxt) {
} }
count++; count++;
if (count > 50) { if (count > 50) {
SHRINK;
GROW; GROW;
count = 0; count = 0;
if (ctxt->instate == XML_PARSER_EOF) { if (ctxt->instate == XML_PARSER_EOF) {
...@@ -4291,6 +4292,7 @@ xmlParsePubidLiteral(xmlParserCtxtPtr ctxt) { ...@@ -4291,6 +4292,7 @@ xmlParsePubidLiteral(xmlParserCtxtPtr ctxt) {
buf[len++] = cur; buf[len++] = cur;
count++; count++;
if (count > 50) { if (count > 50) {
SHRINK;
GROW; GROW;
count = 0; count = 0;
if (ctxt->instate == XML_PARSER_EOF) { if (ctxt->instate == XML_PARSER_EOF) {
...@@ -4571,6 +4573,7 @@ xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int cdata) { ...@@ -4571,6 +4573,7 @@ xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int cdata) {
} }
count++; count++;
if (count > 50) { if (count > 50) {
SHRINK;
GROW; GROW;
count = 0; count = 0;
if (ctxt->instate == XML_PARSER_EOF) if (ctxt->instate == XML_PARSER_EOF)
...@@ -4776,6 +4779,7 @@ xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf, ...@@ -4776,6 +4779,7 @@ xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf,
count++; count++;
if (count > 50) { if (count > 50) {
SHRINK;
GROW; GROW;
count = 0; count = 0;
if (ctxt->instate == XML_PARSER_EOF) { if (ctxt->instate == XML_PARSER_EOF) {
...@@ -5186,6 +5190,7 @@ xmlParsePI(xmlParserCtxtPtr ctxt) { ...@@ -5186,6 +5190,7 @@ xmlParsePI(xmlParserCtxtPtr ctxt) {
} }
count++; count++;
if (count > 50) { if (count > 50) {
SHRINK;
GROW; GROW;
if (ctxt->instate == XML_PARSER_EOF) { if (ctxt->instate == XML_PARSER_EOF) {
xmlFree(buf); xmlFree(buf);
...@@ -9783,6 +9788,7 @@ xmlParseCDSect(xmlParserCtxtPtr ctxt) { ...@@ -9783,6 +9788,7 @@ xmlParseCDSect(xmlParserCtxtPtr ctxt) {
sl = l; sl = l;
count++; count++;
if (count > 50) { if (count > 50) {
SHRINK;
GROW; GROW;
if (ctxt->instate == XML_PARSER_EOF) { if (ctxt->instate == XML_PARSER_EOF) {
xmlFree(buf); xmlFree(buf);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment