xpath BUGFIX casting empty set to string
diff --git a/src/xpath.c b/src/xpath.c
index 9fe638f..bbd75f1 100644
--- a/src/xpath.c
+++ b/src/xpath.c
@@ -502,6 +502,14 @@
static LY_ERR
cast_node_set_to_string(struct lyxp_set *set, char **str)
{
+ if (!set->used) {
+ *str = strdup("");
+ if (!*str) {
+ LOGMEM_RET(set->ctx);
+ }
+ return LY_SUCCESS;
+ }
+
switch (set->val.nodes[0].type) {
case LYXP_NODE_NONE:
/* invalid */
@@ -8643,8 +8651,6 @@
LY_CHECK_ERR_RET(!set->val.str, LOGMEM(set->ctx), LY_EMEM);
break;
case LYXP_SET_NODE_SET:
- assert(set->used);
-
/* we need the set sorted, it affects the result */
assert(!set_sort(set));