|
|
267d54 |
From d6b6dc7bb5e68fa11cb980bc08c4d9ea3f39b190 Mon Sep 17 00:00:00 2001
|
|
|
267d54 |
From: Daniel Veillard <veillard@redhat.com>
|
|
|
267d54 |
Date: Fri, 20 Nov 2015 14:55:30 +0800
|
|
|
267d54 |
Subject: [PATCH] Add xmlHaltParser() to stop the parser
|
|
|
267d54 |
To: libvir-list@redhat.com
|
|
|
267d54 |
|
|
|
267d54 |
The problem is doing it in a consistent and safe fashion
|
|
|
267d54 |
It's more complex than just setting ctxt->instate = XML_PARSER_EOF
|
|
|
267d54 |
Update the public function to reuse that new internal routine
|
|
|
267d54 |
|
|
|
267d54 |
Signed-off-by: Daniel Veillard <veillard@redhat.com>
|
|
|
267d54 |
---
|
|
|
267d54 |
parser.c | 34 +++++++++++++++++++++++++++++-----
|
|
|
267d54 |
1 file changed, 29 insertions(+), 5 deletions(-)
|
|
|
267d54 |
|
|
|
267d54 |
diff --git a/parser.c b/parser.c
|
|
|
267d54 |
index e536e54..5b4f719 100644
|
|
|
267d54 |
--- a/parser.c
|
|
|
267d54 |
+++ b/parser.c
|
|
|
267d54 |
@@ -94,6 +94,8 @@ static xmlParserCtxtPtr
|
|
|
267d54 |
xmlCreateEntityParserCtxtInternal(const xmlChar *URL, const xmlChar *ID,
|
|
|
267d54 |
const xmlChar *base, xmlParserCtxtPtr pctx);
|
|
|
267d54 |
|
|
|
267d54 |
+static void xmlHaltParser(xmlParserCtxtPtr ctxt);
|
|
|
267d54 |
+
|
|
|
267d54 |
/************************************************************************
|
|
|
267d54 |
* *
|
|
|
267d54 |
* Arbitrary limits set in the parser. See XML_PARSE_HUGE *
|
|
|
267d54 |
@@ -12558,25 +12560,47 @@ xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
|
|
|
267d54 |
#endif /* LIBXML_PUSH_ENABLED */
|
|
|
267d54 |
|
|
|
267d54 |
/**
|
|
|
267d54 |
- * xmlStopParser:
|
|
|
267d54 |
+ * xmlHaltParser:
|
|
|
267d54 |
* @ctxt: an XML parser context
|
|
|
267d54 |
*
|
|
|
267d54 |
- * Blocks further parser processing
|
|
|
267d54 |
+ * Blocks further parser processing don't override error
|
|
|
267d54 |
+ * for internal use
|
|
|
267d54 |
*/
|
|
|
267d54 |
-void
|
|
|
267d54 |
-xmlStopParser(xmlParserCtxtPtr ctxt) {
|
|
|
267d54 |
+static void
|
|
|
267d54 |
+xmlHaltParser(xmlParserCtxtPtr ctxt) {
|
|
|
267d54 |
if (ctxt == NULL)
|
|
|
267d54 |
return;
|
|
|
267d54 |
ctxt->instate = XML_PARSER_EOF;
|
|
|
267d54 |
- ctxt->errNo = XML_ERR_USER_STOP;
|
|
|
267d54 |
ctxt->disableSAX = 1;
|
|
|
267d54 |
if (ctxt->input != NULL) {
|
|
|
267d54 |
+ /*
|
|
|
267d54 |
+ * in case there was a specific allocation deallocate before
|
|
|
267d54 |
+ * overriding base
|
|
|
267d54 |
+ */
|
|
|
267d54 |
+ if (ctxt->input->free != NULL) {
|
|
|
267d54 |
+ ctxt->input->free((xmlChar *) ctxt->input->base);
|
|
|
267d54 |
+ ctxt->input->free = NULL;
|
|
|
267d54 |
+ }
|
|
|
267d54 |
ctxt->input->cur = BAD_CAST"";
|
|
|
267d54 |
ctxt->input->base = ctxt->input->cur;
|
|
|
267d54 |
}
|
|
|
267d54 |
}
|
|
|
267d54 |
|
|
|
267d54 |
/**
|
|
|
267d54 |
+ * xmlStopParser:
|
|
|
267d54 |
+ * @ctxt: an XML parser context
|
|
|
267d54 |
+ *
|
|
|
267d54 |
+ * Blocks further parser processing
|
|
|
267d54 |
+ */
|
|
|
267d54 |
+void
|
|
|
267d54 |
+xmlStopParser(xmlParserCtxtPtr ctxt) {
|
|
|
267d54 |
+ if (ctxt == NULL)
|
|
|
267d54 |
+ return;
|
|
|
267d54 |
+ xmlHaltParser(ctxt);
|
|
|
267d54 |
+ ctxt->errNo = XML_ERR_USER_STOP;
|
|
|
267d54 |
+}
|
|
|
267d54 |
+
|
|
|
267d54 |
+/**
|
|
|
267d54 |
* xmlCreateIOParserCtxt:
|
|
|
267d54 |
* @sax: a SAX handler
|
|
|
267d54 |
* @user_data: The user data returned on SAX callbacks
|
|
|
267d54 |
--
|
|
|
267d54 |
2.5.0
|
|
|
267d54 |
|