xpath BUGFIX DFS for top-level nodes without children
diff --git a/src/xpath.c b/src/xpath.c
index d4ff63c..f8997b6 100644
--- a/src/xpath.c
+++ b/src/xpath.c
@@ -6231,7 +6231,7 @@
next = lysc_node_child(iter);
if (!next) {
/* no children, try siblings */
- if (iter == stop) {
+ if ((iter == stop) || !lysc_data_parent(iter)) {
/* we are done, no next element to process */
return NULL;
}
@@ -6241,7 +6241,7 @@
while (!next && iter) {
/* parent is already processed, go to its sibling */
iter = iter->parent;
- if (iter == stop) {
+ if ((iter == stop) || !lysc_data_parent(iter)) {
/* we are done, no next element to process */
return NULL;
}