Blame SOURCES/libxml2-Reuse-xmlHaltParser-where-it-makes-sense.patch

267d54
From 586849318286965d6ede2932ccd31176b4f7fe81 Mon Sep 17 00:00:00 2001
267d54
From: Daniel Veillard <veillard@redhat.com>
267d54
Date: Fri, 20 Nov 2015 14:59:30 +0800
267d54
Subject: [PATCH] Reuse xmlHaltParser() where it makes sense
267d54
To: libvir-list@redhat.com
267d54
267d54
Unify the various place where either xmlStopParser was called
267d54
(which resets the error as a side effect) and places where we
267d54
used ctxt->instate = XML_PARSER_EOF to stop further processing
267d54
267d54
Signed-off-by: Daniel Veillard <veillard@redhat.com>
267d54
---
267d54
 parser.c | 37 +++++++++++++++++--------------------
267d54
 1 file changed, 17 insertions(+), 20 deletions(-)
267d54
267d54
diff --git a/parser.c b/parser.c
267d54
index 5b4f719..9aed98d 100644
267d54
--- a/parser.c
267d54
+++ b/parser.c
267d54
@@ -1773,7 +1773,7 @@ nodePush(xmlParserCtxtPtr ctxt, xmlNodePtr value)
267d54
 	xmlFatalErrMsgInt(ctxt, XML_ERR_INTERNAL_ERROR,
267d54
 		 "Excessive depth in document: %d use XML_PARSE_HUGE option\n",
267d54
 			  xmlParserMaxDepth);
267d54
-	ctxt->instate = XML_PARSER_EOF;
267d54
+	xmlHaltParser(ctxt);
267d54
 	return(-1);
267d54
     }
267d54
     ctxt->nodeTab[ctxt->nodeNr] = value;
267d54
@@ -5655,7 +5655,7 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
267d54
 	if (RAW != '>') {
267d54
 	    xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_NOT_FINISHED,
267d54
 	            "xmlParseEntityDecl: entity %s not terminated\n", name);
267d54
-	    xmlStopParser(ctxt);
267d54
+	    xmlHaltParser(ctxt);
267d54
 	} else {
267d54
 	    if (input != ctxt->input) {
267d54
 		xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
267d54
@@ -6767,8 +6767,7 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
267d54
 	SKIP_BLANKS;
267d54
 	if (RAW != '[') {
267d54
 	    xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID, NULL);
267d54
-	    xmlStopParser(ctxt);
267d54
-	    ctxt->errNo = XML_ERR_CONDSEC_INVALID;
267d54
+	    xmlHaltParser(ctxt);
267d54
 	    return;
267d54
 	} else {
267d54
 	    if (ctxt->input->id != id) {
267d54
@@ -6830,8 +6829,7 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
267d54
 	SKIP_BLANKS;
267d54
 	if (RAW != '[') {
267d54
 	    xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID, NULL);
267d54
-	    xmlStopParser(ctxt);
267d54
-	    ctxt->errNo = XML_ERR_CONDSEC_INVALID;
267d54
+	    xmlHaltParser(ctxt);
267d54
 	    return;
267d54
 	} else {
267d54
 	    if (ctxt->input->id != id) {
267d54
@@ -6888,8 +6886,7 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
267d54
 
267d54
     } else {
267d54
 	xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID_KEYWORD, NULL);
267d54
-	xmlStopParser(ctxt);
267d54
-	ctxt->errNo = XML_ERR_CONDSEC_INVALID_KEYWORD;
267d54
+	xmlHaltParser(ctxt);
267d54
 	return;
267d54
     }
267d54
 
267d54
@@ -7100,7 +7097,7 @@ xmlParseExternalSubset(xmlParserCtxtPtr ctxt, const xmlChar *ExternalID,
267d54
 	    /*
267d54
 	     * The XML REC instructs us to stop parsing right here
267d54
 	     */
267d54
-	    ctxt->instate = XML_PARSER_EOF;
267d54
+	    xmlHaltParser(ctxt);
267d54
 	    return;
267d54
 	}
267d54
     }
267d54
@@ -8087,7 +8084,7 @@ xmlParsePEReference(xmlParserCtxtPtr ctxt)
267d54
 		     * The XML REC instructs us to stop parsing
267d54
 		     * right here
267d54
 		     */
267d54
-		    ctxt->instate = XML_PARSER_EOF;
267d54
+		    xmlHaltParser(ctxt);
267d54
 		    return;
267d54
 		}
267d54
 	    }
267d54
@@ -9986,7 +9983,7 @@ xmlParseContent(xmlParserCtxtPtr ctxt) {
267d54
 	if ((cons == ctxt->input->consumed) && (test == CUR_PTR)) {
267d54
 	    xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
267d54
 	                "detected an error in element content\n");
267d54
-	    ctxt->instate = XML_PARSER_EOF;
267d54
+	    xmlHaltParser(ctxt);
267d54
             break;
267d54
 	}
267d54
     }
267d54
@@ -10021,7 +10018,7 @@ xmlParseElement(xmlParserCtxtPtr ctxt) {
267d54
 	xmlFatalErrMsgInt(ctxt, XML_ERR_INTERNAL_ERROR,
267d54
 		 "Excessive depth in document: %d use XML_PARSE_HUGE option\n",
267d54
 			  xmlParserMaxDepth);
267d54
-	ctxt->instate = XML_PARSER_EOF;
267d54
+	xmlHaltParser(ctxt);
267d54
 	return;
267d54
     }
267d54
 
267d54
@@ -11345,7 +11342,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
267d54
 			ctxt->sax->setDocumentLocator(ctxt->userData,
267d54
 						      &xmlDefaultSAXLocator);
267d54
 		    xmlFatalErr(ctxt, XML_ERR_DOCUMENT_EMPTY, NULL);
267d54
-		    ctxt->instate = XML_PARSER_EOF;
267d54
+		    xmlHaltParser(ctxt);
267d54
 #ifdef DEBUG_PUSH
267d54
 		    xmlGenericError(xmlGenericErrorContext,
267d54
 			    "PP: entering EOF\n");
267d54
@@ -11378,7 +11375,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
267d54
 			     * The XML REC instructs us to stop parsing right
267d54
 			     * here
267d54
 			     */
267d54
-			    ctxt->instate = XML_PARSER_EOF;
267d54
+			    xmlHaltParser(ctxt);
267d54
 			    return(0);
267d54
 			}
267d54
 			ctxt->standalone = ctxt->input->standalone;
267d54
@@ -11434,7 +11431,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
267d54
 		cur = ctxt->input->cur[0];
267d54
 	        if (cur != '<') {
267d54
 		    xmlFatalErr(ctxt, XML_ERR_DOCUMENT_EMPTY, NULL);
267d54
-		    ctxt->instate = XML_PARSER_EOF;
267d54
+		    xmlHaltParser(ctxt);
267d54
 		    if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
267d54
 			ctxt->sax->endDocument(ctxt->userData);
267d54
 		    goto done;
267d54
@@ -11466,7 +11463,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
267d54
 		    goto done;
267d54
 		if (name == NULL) {
267d54
 		    spacePop(ctxt);
267d54
-		    ctxt->instate = XML_PARSER_EOF;
267d54
+		    xmlHaltParser(ctxt);
267d54
 		    if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
267d54
 			ctxt->sax->endDocument(ctxt->userData);
267d54
 		    goto done;
267d54
@@ -11633,7 +11630,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
267d54
 		if ((cons == ctxt->input->consumed) && (test == CUR_PTR)) {
267d54
 		    xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
267d54
 		                "detected an error in element content\n");
267d54
-		    ctxt->instate = XML_PARSER_EOF;
267d54
+		    xmlHaltParser(ctxt);
267d54
 		    break;
267d54
 		}
267d54
 		break;
267d54
@@ -11954,7 +11951,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
267d54
 		    goto done;
267d54
 		} else {
267d54
 		    xmlFatalErr(ctxt, XML_ERR_DOCUMENT_END, NULL);
267d54
-		    ctxt->instate = XML_PARSER_EOF;
267d54
+		    xmlHaltParser(ctxt);
267d54
 #ifdef DEBUG_PUSH
267d54
 		    xmlGenericError(xmlGenericErrorContext,
267d54
 			    "PP: entering EOF\n");
267d54
@@ -12318,7 +12315,7 @@ xmldecl_done:
267d54
 	res = xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
267d54
 	if (res < 0) {
267d54
 	    ctxt->errNo = XML_PARSER_EOF;
267d54
-	    ctxt->disableSAX = 1;
267d54
+	    xmlHaltParser(ctxt);
267d54
 	    return (XML_PARSER_EOF);
267d54
 	}
267d54
         xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input, base, cur);
267d54
@@ -12372,7 +12369,7 @@ xmldecl_done:
267d54
          ((ctxt->input->cur - ctxt->input->base) > XML_MAX_LOOKUP_LIMIT)) &&
267d54
         ((ctxt->options & XML_PARSE_HUGE) == 0)) {
267d54
         xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR, "Huge input lookup");
267d54
-        ctxt->instate = XML_PARSER_EOF;
267d54
+        xmlHaltParser(ctxt);
267d54
     }
267d54
     if ((ctxt->errNo != XML_ERR_OK) && (ctxt->disableSAX == 1))
267d54
         return(ctxt->errNo);
267d54
-- 
267d54
2.5.0
267d54