diff --git a/src/path.c b/src/path.c index d5e59dce7..e72ecac5e 100644 --- a/src/path.c +++ b/src/path.c @@ -931,7 +931,7 @@ ly_path_dup_predicates(const struct ly_ctx *ctx, const struct ly_path_predicate LYA_PREALLOC(*dup, LYA_COUNT(pred), LOGMEM(ctx); return LY_EMEM); LYA_FOR(pred, u) { LYA_INCREMENT(*dup); - (*dup)[u].type = pred->type; + (*dup)[u].type = pred[u].type; switch (pred[u].type) { case LY_PATH_PREDTYPE_POSITION: diff --git a/tests/utests/types/instanceid.c b/tests/utests/types/instanceid.c index 02e9b9fe5..683ad6932 100644 --- a/tests/utests/types/instanceid.c +++ b/tests/utests/types/instanceid.c @@ -281,12 +281,37 @@ test_plugin_lyb(void **state) TEST_SUCCESS_LYB2("lyb2", "nii", "ll[. = 'some_string']"); } +static void +test_plugin_dup(void **state) +{ + const char *schema, *data; + struct lyd_node *tree, *dup; + + /* ietf-netconf-acm node-instance-identifier type with mixed key predicates */ + assert_int_equal(LY_SUCCESS, ly_ctx_set_searchdir(UTEST_LYCTX, TESTS_DIR_MODULES_YANG)); + schema = MODULE_CREATE_YANG("dup", + "import ietf-netconf-acm {prefix acm;}" + "list lst {key \"k1 k2\"; leaf k1 {type string;} leaf k2 {type string;}}" + "leaf-list nii {type acm:node-instance-identifier;}"); + UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL); + + data = "/aa:lst[aa:k1='a'][aa:k2=$x]" + "/aa:lst[aa:k1=$x][aa:k2='a']"; + CHECK_PARSE_LYD_PARAM(data, LYD_XML, LYD_PARSE_ONLY | LYD_PARSE_STRICT, 0, LY_SUCCESS, tree); + + assert_int_equal(LY_SUCCESS, lyd_dup_siblings(tree, NULL, 0, &dup)); + CHECK_LYD(tree, dup); + lyd_free_all(dup); + lyd_free_all(tree); +} + int main(void) { const struct CMUnitTest tests[] = { UTEST(test_data_xml), UTEST(test_plugin_lyb), + UTEST(test_plugin_dup), }; return cmocka_run_group_tests(tests, NULL, NULL);