Skip to content

Commit 0ee491b

Browse files
committed
tree data BUGFIX double hash insert
Fixes #2393
1 parent 4d3259c commit 0ee491b

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/tree_data_new.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,10 @@ lyd_change_node_value(struct lyd_node_term *term, struct lyd_value *val, ly_bool
12871287
rc = ((struct lysc_node_leaf *)term->schema)->type->plugin->duplicate(LYD_CTX(term), val, &term->value);
12881288
}
12891289

1290-
/* reinserting */
1290+
/* update hash */
1291+
lyd_hash(target);
1292+
1293+
/* reinsert */
12911294
lyd_insert_node(NULL, &first, target, LYD_INSERT_NODE_DEFAULT);
12921295
} else {
12931296
/* unlink hash */
@@ -1298,12 +1301,15 @@ lyd_change_node_value(struct lyd_node_term *term, struct lyd_value *val, ly_bool
12981301
if (use_val) {
12991302
term->value = *val;
13001303
} else {
1301-
rc = ((struct lysc_node_leaf *)term->schema)->type->plugin->duplicate(LYD_CTX(term), val, &term->value);
1304+
LY_CHECK_RET(((struct lysc_node_leaf *)term->schema)->type->plugin->duplicate(LYD_CTX(term), val, &term->value));
13021305
}
1303-
}
13041306

1305-
lyd_hash(target);
1306-
rc = lyd_insert_hash(target);
1307+
/* update hash */
1308+
lyd_hash(target);
1309+
1310+
/* reinsert hash */
1311+
LY_CHECK_RET(lyd_insert_hash(target));
1312+
}
13071313

13081314
return rc;
13091315
}

0 commit comments

Comments
 (0)