diff --git a/lib/src/clixon_xml_map.c b/lib/src/clixon_xml_map.c
index 13801e22..8e7e6461 100644
--- a/lib/src/clixon_xml_map.c
+++ b/lib/src/clixon_xml_map.c
@@ -528,8 +528,7 @@ cvec2xml_1(cvec *cvv,
* @see xml_diff API function, this one is internal and recursive
*/
static int
-xml_diff1(yang_stmt *ys,
- cxobj *x0,
+xml_diff1(cxobj *x0,
cxobj *x1,
cxobj ***x0vec,
int *x0veclen,
@@ -581,11 +580,11 @@ xml_diff1(yang_stmt *ys,
continue;
}
else{ /* equal */
- if ((yc = xml_spec(x0c)) == NULL){
- clicon_err(OE_UNIX, errno, "Unknown element: %s", xml_name(x0c));
- goto done;
- }
- if (yang_choice(yc)){
+ /* xml-spec NULL could happen with anydata children for example,
+ * if so, continute compare children but without yang
+ */
+ yc = xml_spec(x0c);
+ if (yc && yang_choice(yc)){
/* if x0c and x1c are choice/case, then they are changed */
if (cxvec_append(x0c, changed_x0, changedlen) < 0)
goto done;
@@ -593,7 +592,7 @@ xml_diff1(yang_stmt *ys,
if (cxvec_append(x1c, changed_x1, changedlen) < 0)
goto done;
}
- else if (yang_keyword_get(yc) == Y_LEAF){
+ else if (yc && yang_keyword_get(yc) == Y_LEAF){
/* if x0c and x1c are leafs w bodies, then they are changed */
if ((b1 = xml_body(x0c)) == NULL) /* empty type */
break;
@@ -607,7 +606,7 @@ xml_diff1(yang_stmt *ys,
goto done;
}
}
- else if (xml_diff1(yc, x0c, x1c,
+ else if (xml_diff1(x0c, x1c,
x0vec, x0veclen,
x1vec, x1veclen,
changed_x0, changed_x1, changedlen)< 0)
@@ -664,7 +663,7 @@ xml_diff(yang_stmt *yspec,
goto done;
goto ok;
}
- if (xml_diff1((yang_stmt*)yspec, x0, x1,
+ if (xml_diff1(x0, x1,
first, firstlen,
second, secondlen,
changed_x0, changed_x1, changedlen) < 0)
diff --git a/lib/src/clixon_yang.c b/lib/src/clixon_yang.c
index 5e92dc90..b10559a3 100644
--- a/lib/src/clixon_yang.c
+++ b/lib/src/clixon_yang.c
@@ -2854,19 +2854,24 @@ yang_type_cache_free(yang_type_cache *ycache)
*
* One usecase is CLICON_YANG_UNKNOWN_ANYDATA when unknown data is treated as anydata
* @param[in] yp Yang parent statement
- * @param[in] name Node name
+ * @param[in] name Node name, will be copied
* @retval ys OK
* @retval NULL Error
* @see ysp_add
*/
yang_stmt *
yang_anydata_add(yang_stmt *yp,
- char *name)
+ char *name0)
{
yang_stmt *ys = NULL;
+ char *name = NULL;
if ((ys = ys_new(Y_ANYDATA)) == NULL)
goto done;
+ if ((name = strdup(name0)) == NULL){
+ clicon_err(OE_UNIX, errno, "strdup");
+ goto done;
+ }
yang_argument_set(ys, name);
if (yn_insert(yp, ys) < 0){ /* Insert into hierarchy */
ys = NULL;
diff --git a/test/test_yang_anydata.sh b/test/test_yang_anydata.sh
index 3a1d873a..1966c1d8 100755
--- a/test/test_yang_anydata.sh
+++ b/test/test_yang_anydata.sh
@@ -77,9 +77,9 @@ module unknown{
EOF
# For edit config
-XMLA='2255a string23'
+XMLA='2242a string23'
-XMLU='2255a string23'
+XMLU='2242a string23'
# Full state
STATE0='2255a string2255a string'
@@ -178,6 +178,13 @@ EOF
new "Get running"
expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^$XML]]>]]>$"
+ # Add other functions, (based on previous errors), eg cli show config, cli commit.
+ new "cli show configuration"
+ expectpart "$($clixon_cli -1 -f $cfg show conf xml)" 0 "42"
+
+ new "cli commit"
+ expectpart "$($clixon_cli -1 -f $cfg commit)" 0 "^$"
+
if $unknown; then
STATE="$STATE0" # full state
else