diff --git a/HTMLparser.c b/HTMLparser.c
index 1699aae4..59c01162 100644
--- a/HTMLparser.c
+++ b/HTMLparser.c
@@ -4085,11 +4085,12 @@ htmlParseEndTag(htmlParserCtxtPtr ctxt)
static void
htmlParseContent(htmlParserCtxtPtr ctxt) {
+ GROW;
+
while ((PARSER_STOPPED(ctxt) == 0) &&
(ctxt->input->cur < ctxt->input->end)) {
int mode;
- GROW;
mode = ctxt->endCheckState;
if ((mode == 0) && (CUR == '<')) {
@@ -4265,7 +4266,7 @@ htmlCtxtParseContentInternal(htmlParserCtxtPtr ctxt, xmlParserInputPtr input) {
return(NULL);
}
- if (xmlPushInput(ctxt, input) < 0) {
+ if (xmlCtxtPushInput(ctxt, input) < 0) {
xmlFreeNode(root);
return(NULL);
}
@@ -4292,7 +4293,6 @@ htmlCtxtParseContentInternal(htmlParserCtxtPtr ctxt, xmlParserInputPtr input) {
nodePop(ctxt);
htmlnamePop(ctxt);
- /* xmlPopInput would free the stream */
xmlCtxtPopInput(ctxt);
xmlFreeNode(root);
diff --git a/SAX2.c b/SAX2.c
index 40e21ce1..087368dd 100644
--- a/SAX2.c
+++ b/SAX2.c
@@ -325,7 +325,7 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
ctxt->inputNr = 0;
ctxt->inputMax = 5;
ctxt->input = NULL;
- if (xmlPushInput(ctxt, input) < 0)
+ if (xmlCtxtPushInput(ctxt, input) < 0)
goto error;
if (input->filename == NULL)
@@ -346,7 +346,7 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
*/
while (ctxt->inputNr > 1)
- xmlPopInput(ctxt);
+ xmlFreeInputStream(xmlCtxtPopInput(ctxt));
consumed = ctxt->input->consumed;
buffered = ctxt->input->cur - ctxt->input->base;
diff --git a/parser.c b/parser.c
index f781f8e9..df517e96 100644
--- a/parser.c
+++ b/parser.c
@@ -2507,9 +2507,11 @@ xmlPopPE(xmlParserCtxtPtr ctxt) {
ent->flags |= XML_ENT_CHECKED;
}
- xmlPopInput(ctxt);
+ xmlFreeInputStream(xmlCtxtPopInput(ctxt));
xmlParserEntityCheck(ctxt, ent->expandedSize);
+
+ GROW;
}
/**
@@ -2589,9 +2591,6 @@ xmlSkipBlankCharsPE(xmlParserCtxtPtr ctxt) {
*
* DEPRECATED: Internal function, don't use.
*
- * xmlPopInput: the current input pointed by ctxt->input came to an end
- * pop it and return the next char.
- *
* Returns the current xmlChar in the parser context
*/
xmlChar
@@ -7936,13 +7935,15 @@ xmlParsePEReference(xmlParserCtxtPtr ctxt)
}
input = xmlNewEntityInputStream(ctxt, entity);
- if (xmlPushInput(ctxt, input) < 0) {
+ if (xmlCtxtPushInput(ctxt, input) < 0) {
xmlFreeInputStream(input);
return;
}
entity->flags |= XML_ENT_EXPANDING;
+ GROW;
+
if (entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) {
xmlDetectEncoding(ctxt);
@@ -11777,7 +11778,7 @@ xmlCtxtParseDtd(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
const xmlChar *publicId, const xmlChar *systemId) {
xmlDtdPtr ret;
- if (xmlPushInput(ctxt, input) < 0) {
+ if (xmlCtxtPushInput(ctxt, input) < 0) {
xmlFreeInputStream(input);
return(NULL);
}
@@ -11981,7 +11982,7 @@ xmlCtxtParseContentInternal(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
}
}
- if (xmlPushInput(ctxt, input) < 0)
+ if (xmlCtxtPushInput(ctxt, input) < 0)
goto error;
nameNsPush(ctxt, rootName, NULL, NULL, 0, 0);
@@ -12048,7 +12049,6 @@ xmlCtxtParseContentInternal(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
namePop(ctxt);
spacePop(ctxt);
- /* xmlPopInput would free the stream */
xmlCtxtPopInput(ctxt);
error:
@@ -12111,7 +12111,7 @@ xmlCtxtParseEntity(xmlParserCtxtPtr ctxt, xmlEntityPtr ent) {
* - xmlCtxtParseEntity
*
* The nesting depth is limited by the maximum number of inputs,
- * see xmlPushInput.
+ * see xmlCtxtPushInput.
*
* It's possible to make this non-recursive (minNsIndex must be
* stored in the input struct) at the expense of code readability.