Skip to content

Commit d6a4806

Browse files
committed
fixup! resolve BUGFIX do not delete false when data when not possible to check when
1 parent edf1592 commit d6a4806

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

src/parser_xml.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,12 @@ lyd_parse_xml(struct ly_ctx *ctx, struct lyxml_elem **root, int options, ...)
602602
if (options & (LYD_OPT_RPC | LYD_OPT_NOTIF | LYD_OPT_RPCREPLY)) {
603603
data_tree = va_arg(ap, const struct lyd_node *);
604604
if (data_tree) {
605+
if (options & LYD_OPT_NOEXTDEPS) {
606+
LOGERR(LY_EINVAL, "%s: invalid parameter (variable arg const struct lyd_node *data_tree and LYD_OPT_NOEXTDEPS set).",
607+
__func__);
608+
goto cleanup;
609+
}
610+
605611
LY_TREE_FOR((struct lyd_node *)data_tree, iter) {
606612
if (iter->parent) {
607613
/* a sibling is not top-level */
@@ -618,10 +624,6 @@ lyd_parse_xml(struct ly_ctx *ctx, struct lyxml_elem **root, int options, ...)
618624
LOGERR(LY_EINVAL, "%s: invalid parameter (variable arg const struct lyd_node *data_tree with LYD_OPT_NOSIBLINGS).", __func__);
619625
goto error;
620626
}
621-
} else if (options & LYD_OPT_NOEXTDEPS) {
622-
LOGERR(LY_EINVAL, "%s: invalid parameter (no variable arg const struct lyd_node *data_tree but LYD_OPT_NOEXTDEPS set).",
623-
__func__);
624-
goto error;
625627
}
626628
}
627629

src/tree_data.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,12 @@ lyd_parse_data_(struct ly_ctx *ctx, const char *data, LYD_FORMAT format, int opt
462462
if (options & (LYD_OPT_RPC | LYD_OPT_NOTIF | LYD_OPT_RPCREPLY)) {
463463
data_tree = va_arg(ap, const struct lyd_node *);
464464
if (data_tree) {
465+
if (options & LYD_OPT_NOEXTDEPS) {
466+
LOGERR(LY_EINVAL, "%s: invalid parameter (variable arg const struct lyd_node *data_tree and LYD_OPT_NOEXTDEPS set).",
467+
__func__);
468+
return NULL;
469+
}
470+
465471
LY_TREE_FOR(data_tree, iter) {
466472
if (iter->parent) {
467473
/* a sibling is not top-level */
@@ -478,10 +484,6 @@ lyd_parse_data_(struct ly_ctx *ctx, const char *data, LYD_FORMAT format, int opt
478484
LOGERR(LY_EINVAL, "%s: invalid parameter (variable arg const struct lyd_node *data_tree with LYD_OPT_NOSIBLINGS).", __func__);
479485
return NULL;
480486
}
481-
} else if (options & LYD_OPT_NOEXTDEPS) {
482-
LOGERR(LY_EINVAL, "%s: invalid parameter (no variable arg const struct lyd_node *data_tree but LYD_OPT_NOEXTDEPS set).",
483-
__func__);
484-
return NULL;
485487
}
486488
}
487489

@@ -4163,6 +4165,12 @@ lyd_validate(struct lyd_node **node, int options, void *var_arg)
41634165
/* get the additional data tree if given */
41644166
data_tree = (struct lyd_node *)var_arg;
41654167
if (data_tree) {
4168+
else if (options & LYD_OPT_NOEXTDEPS) {
4169+
LOGERR(LY_EINVAL, "%s: invalid parameter (variable arg const struct lyd_node *data_tree and LYD_OPT_NOEXTDEPS set).",
4170+
__func__);
4171+
goto cleanup;
4172+
}
4173+
41664174
LY_TREE_FOR(data_tree, iter) {
41674175
if (iter->parent) {
41684176
/* a sibling is not top-level */
@@ -4173,10 +4181,6 @@ lyd_validate(struct lyd_node **node, int options, void *var_arg)
41734181

41744182
/* move it to the beginning */
41754183
for (; data_tree->prev->next; data_tree = data_tree->prev);
4176-
} else if (options & LYD_OPT_NOEXTDEPS) {
4177-
LOGERR(LY_EINVAL, "%s: invalid parameter (no variable arg const struct lyd_node *data_tree but LYD_OPT_NOEXTDEPS set).",
4178-
__func__);
4179-
goto cleanup;
41804184
}
41814185
}
41824186

0 commit comments

Comments
 (0)