[xml] addSibling missing check for element equality


The functions xmlAddNextSibling and xmlAddPrevSibling have a check which checks if the element to be added is the same as the reference element. xmlAddSibling however does not have such a check, resulting in the loss of the element (the call to xmlUnlinkNode(elem) will unlink cur). I think the equality check should be added to addSibling as well, like in the attached patch.

Kris Breuker
--- tree.c      Sat Jan 17 14:45:34 2009
+++ tree_patched.c      Wed Mar 11 12:16:22 2009
@@ -3103,6 +3103,14 @@
+    if (cur == elem) {
+#ifdef DEBUG_TREE
+        xmlGenericError(xmlGenericErrorContext,
+               "xmlAddSibling : cur == elem\n");
+       return(NULL);
+    }
      * Constant time is we can rely on the ->parent->last to find
      * the last sibling.

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