NextSibling() segfault when called on the root node, so add a check
[SXSI/XMLTree.git] / XMLTree.cpp
index 92360a4..3c51b2f 100644 (file)
@@ -345,7 +345,9 @@ treeNode XMLTree::NextSibling(treeNode x)
        fprintf(stderr, "Error: data structure has not been constructed properly\n");\r
        exit(1);\r
     }\r
-\r
+    if (x == Root())\r
+      return NULLT;\r
\r
     return next_sibling(Par, x);\r
  }\r
 \r