Skip to content

Commit

Permalink
parser.c: shrink the input buffer when appropriate
Browse files Browse the repository at this point in the history
Fixes GNOME/libxml2#200

Also see discussions at:
- GNOME/libxml2#192
- https://gitlab.gnome.org/nwellnhof/libxml2/-/commit/99bda1e
- sparklemotion/nokogiri#2132
  • Loading branch information
flavorjones authored and nwellnhof committed Feb 8, 2021
1 parent ec808a4 commit afad372
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions parser.c
Expand Up @@ -4204,6 +4204,7 @@ xmlParseSystemLiteral(xmlParserCtxtPtr ctxt) {
}
count++;
if (count > 50) {
SHRINK;
GROW;
count = 0;
if (ctxt->instate == XML_PARSER_EOF) {
Expand Down Expand Up @@ -4291,6 +4292,7 @@ xmlParsePubidLiteral(xmlParserCtxtPtr ctxt) {
buf[len++] = cur;
count++;
if (count > 50) {
SHRINK;
GROW;
count = 0;
if (ctxt->instate == XML_PARSER_EOF) {
Expand Down Expand Up @@ -4571,6 +4573,7 @@ xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int cdata) {
}
count++;
if (count > 50) {
SHRINK;
GROW;
count = 0;
if (ctxt->instate == XML_PARSER_EOF)
Expand Down Expand Up @@ -4776,6 +4779,7 @@ xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf,

count++;
if (count > 50) {
SHRINK;
GROW;
count = 0;
if (ctxt->instate == XML_PARSER_EOF) {
Expand Down Expand Up @@ -5186,6 +5190,7 @@ xmlParsePI(xmlParserCtxtPtr ctxt) {
}
count++;
if (count > 50) {
SHRINK;
GROW;
if (ctxt->instate == XML_PARSER_EOF) {
xmlFree(buf);
Expand Down Expand Up @@ -9783,6 +9788,7 @@ xmlParseCDSect(xmlParserCtxtPtr ctxt) {
sl = l;
count++;
if (count > 50) {
SHRINK;
GROW;
if (ctxt->instate == XML_PARSER_EOF) {
xmlFree(buf);
Expand Down

0 comments on commit afad372

Please sign in to comment.