Skip to content

Commit cd5fd5f

Browse files
committed
tree data UPDATE correctly unlink list keys
List keys were not correctly unlinked leading to wrong hashes.
1 parent 17265ec commit cd5fd5f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/tree_data.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,19 @@ lyd_unlink_ignore_lyds(struct lyd_node **first_sibling_p, struct lyd_node *node)
12061206
/* check for NP container whether its last non-default node is not being unlinked */
12071207
lyd_np_cont_dflt_set(lyd_parent(node));
12081208

1209+
/* when unlinking duplicate key we need to recalculate the list hash */
1210+
if (node->schema && (node->schema->flags & LYS_KEY) && node->parent->schema &&
1211+
lyd_insert_has_keys(lyd_parent(node))) {
1212+
/* unlink the list instance */
1213+
lyd_unlink_hash(lyd_parent(node));
1214+
1215+
/* calculate updated instance hash */
1216+
lyd_hash(lyd_parent(node));
1217+
1218+
/* reinsert list into its parent HT */
1219+
lyd_insert_hash(lyd_parent(node));
1220+
}
1221+
12091222
node->parent = NULL;
12101223
}
12111224

0 commit comments

Comments
 (0)