xpath BUGFIX handle root context node
diff --git a/src/xpath.c b/src/xpath.c
index ed24eb1..ddfdc06 100644
--- a/src/xpath.c
+++ b/src/xpath.c
@@ -1637,7 +1637,7 @@
}
/* find first top-level node to be used as anchor for positions */
- for (root = set->cur_node; root->parent; root = lyd_parent(root)) {}
+ for (root = set->tree; root->parent; root = lyd_parent(root)) {}
for ( ; root->prev->next; root = root->prev) {}
/* fill positions */
@@ -4669,7 +4669,9 @@
*pattern = calloc(1, sizeof **pattern);
LOG_LOCSET(NULL, set->cur_node, NULL, NULL);
rc = lys_compile_type_pattern_check(set->ctx, args[1]->val.str, &(*pattern)->code);
- LOG_LOCBACK(0, 1, 0, 0);
+ if (set->cur_node) {
+ LOG_LOCBACK(0, 1, 0, 0);
+ }
if (rc != LY_SUCCESS) {
LY_ARRAY_FREE(patterns);
return rc;
@@ -8735,7 +8737,9 @@
lyxp_set_free_content(set);
}
- LOG_LOCBACK(0, 1, 0, 0);
+ if (set->cur_node) {
+ LOG_LOCBACK(0, 1, 0, 0);
+ }
return rc;
}