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