Skip to content

Commit abc2e3f

Browse files
committed
temp
1 parent 8bc4e39 commit abc2e3f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/tree_data.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ lyd_parse_data_path(const struct ly_ctx *ctx, const char *path, LYD_FORMAT forma
279279
return ret;
280280
}
281281

282+
static int lyd_insert_has_keys(const struct lyd_node *list);
283+
282284
LIBYANG_API_DEF LY_ERR
283285
lyd_parse_value_fragment(const struct ly_ctx *ctx, const char *path, struct ly_in *in, LYD_FORMAT format,
284286
uint32_t new_val_options, uint32_t parse_options, uint32_t validate_options, struct lyd_node **tree)
@@ -289,7 +291,7 @@ lyd_parse_value_fragment(const struct ly_ctx *ctx, const char *path, struct ly_i
289291
struct lyd_node *new_last_parent = NULL, *new_top_parent = NULL;
290292
const struct lysc_node *new_node_schema = NULL;
291293
ly_bool p_decremented = 0;
292-
struct lyd_node *iter = NULL;
294+
struct lyd_node *iter = NULL, *parent = NULL;
293295
const char *key_value = NULL;
294296
const char *path_key_value = NULL;
295297

@@ -341,20 +343,20 @@ lyd_parse_value_fragment(const struct ly_ctx *ctx, const char *path, struct ly_i
341343
LY_CHECK_ERR_GOTO(strcmp(key_value, path_key_value), LOGVAL(ctx, LYVE_DATA,
342344
"Path [%s] contains a different key [%s] than data [%s]", path, path_key_value, key_value);
343345
ret = LY_EINVAL, cleanup);
346+
parent = lyd_parent(iter);
344347
lyd_unlink(iter);
345348
lyd_free_tree(iter);
346349

347350
/* when unlinking duplicate key we need to recalculate the list hash */
348-
if (iter->schema && (iter->schema->flags & LYS_KEY) && iter->parent->schema &&
349-
lyd_insert_has_keys(lyd_parent(iter))) {
351+
if (parent && parent->schema && lyd_insert_has_keys(parent)) {
350352
/* unlink the list instance */
351-
lyd_unlink_hash(lyd_parent(iter));
353+
lyd_unlink_hash(parent);
352354

353355
/* calculate updated instance hash */
354-
lyd_hash(lyd_parent(iter));
356+
lyd_hash(parent);
355357

356358
/* reinsert list into its parent HT */
357-
lyd_insert_hash(lyd_parent(iter));
359+
lyd_insert_hash(parent);
358360
}
359361
break;
360362
}

0 commit comments

Comments
 (0)