NextSibling() segfault when called on the root node, so add a check
authorkim <kim@3cdefd35-fc62-479d-8e8d-bae585ffb9ca>
Tue, 27 Jan 2009 00:04:58 +0000 (00:04 +0000)
committerkim <kim@3cdefd35-fc62-479d-8e8d-bae585ffb9ca>
Tue, 27 Jan 2009 00:04:58 +0000 (00:04 +0000)
and retrung NULLT if the argument is ther root node. It's consistent with
the behaviour of calling FirstChild on a leaf node.

git-svn-id: svn+ssh://idea.nguyen.vg/svn/sxsi/trunk/XMLTree@65 3cdefd35-fc62-479d-8e8d-bae585ffb9ca

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