[libxml2] xmlParseNodeInContext problems with an empty document



commit 71a243d5b4684181abfa21f557568499610c2539
Author: Tim Elliott <tle holymonkey com>
Date:   Tue Jan 17 19:25:08 2012 -0800

    xmlParseNodeInContext problems with an empty document
    
    When you call xmlParseNodeInContext on a fragment node with an
    empty document, the parser associates the first new node twice --
    once with the document, and once with the fragment node.
    
    This fixes the issue by only associating the new node with the
    fragment node.

 SAX2.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/SAX2.c b/SAX2.c
index 453f4c8..126a79f 100644
--- a/SAX2.c
+++ b/SAX2.c
@@ -2242,7 +2242,7 @@ xmlSAX2StartElementNs(void *ctx,
 	}
     }
 
-    if ((ctxt->myDoc->children == NULL) || (parent == NULL)) {
+    if (parent == NULL) {
         xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret);
     }
     /*
@@ -2640,7 +2640,7 @@ xmlSAX2ProcessingInstruction(void *ctx, const xmlChar *target,
 	xmlAddChild((xmlNodePtr) ctxt->myDoc->extSubset, ret);
 	return;
     }
-    if ((ctxt->myDoc->children == NULL) || (parent == NULL)) {
+    if (parent == NULL) {
 #ifdef DEBUG_SAX_TREE
 	    xmlGenericError(xmlGenericErrorContext,
 		    "Setting PI %s as root\n", target);
@@ -2701,7 +2701,7 @@ xmlSAX2Comment(void *ctx, const xmlChar *value)
 	xmlAddChild((xmlNodePtr) ctxt->myDoc->extSubset, ret);
 	return;
     }
-    if ((ctxt->myDoc->children == NULL) || (parent == NULL)) {
+    if (parent == NULL) {
 #ifdef DEBUG_SAX_TREE
 	    xmlGenericError(xmlGenericErrorContext,
 		    "Setting xmlSAX2Comment as root\n");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]