Skip to content

Commit 08f3ad9

Browse files
committed
diff BUGFIX use previous position in diff create
1 parent 6edf345 commit 08f3ad9

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/diff.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,16 @@ lyd_diff_add_create_nested_userord(struct lyd_node *node)
128128
meta_name = "yang:position";
129129

130130
pos = lyd_list_pos(node);
131-
if (asprintf(&dyn, "%" PRIu32, pos) == -1) {
132-
LOGMEM(LYD_CTX(node));
133-
rc = LY_EMEM;
134-
goto cleanup;
131+
if (pos > 1) {
132+
if (asprintf(&dyn, "%" PRIu32, pos - 1) == -1) {
133+
LOGMEM(LYD_CTX(node));
134+
rc = LY_EMEM;
135+
goto cleanup;
136+
}
137+
meta_val = dyn;
138+
} else {
139+
meta_val = "";
135140
}
136-
meta_val = dyn;
137141
} else if (node->schema->nodetype == LYS_LIST) {
138142
meta_name = "yang:key";
139143

0 commit comments

Comments
 (0)