Source

perl-XML-LibXML / xpath.c

Diff from to

File xpath.c

                 froot = froot->parent;
             }
             xmlAddChild((xmlNodePtr)tdoc, froot);
-
-            refNode->doc = tdoc;
+            xmlSetTreeDoc(froot, tdoc); /* probably no need to clean psvi */
+	    froot->doc = tdoc;
+            /* refNode->doc = tdoc; */
         }
 
         /* prepare the xpath context */
         if ( tdoc != NULL ) {
             /* after looking through a fragment, we need to drop the
                fake document again */
-            xmlSetTreeDoc(froot, NULL);
+            xmlSetTreeDoc(froot, NULL); /* probably no need to clean psvi */
 	    froot->doc = NULL;
 	    froot->parent = NULL;
             tdoc->children = NULL;
                 froot = froot->parent;
             }
             xmlAddChild((xmlNodePtr)tdoc, froot);
-	    ctxt->node->doc = tdoc;
+	    xmlSetTreeDoc(froot,tdoc);  /* probably no need to clean psvi */
+            froot->doc = tdoc;
+	    /* ctxt->node->doc = tdoc; */
         }
 	if (to_bool) {
 #if LIBXML_VERSION >= 20627
         if ( tdoc != NULL ) {
             /* after looking through a fragment, we need to drop the
                fake document again */
-	    xmlSetTreeDoc(froot,NULL);
+	    xmlSetTreeDoc(froot,NULL); /* probably no need to clean psvi */
             froot->doc = NULL;
             froot->parent  = NULL;
             tdoc->children = NULL;