Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/parser_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct lysp_ctx;
err_cmd; \
const struct ly_err_item *__eitem = ly_err_last(((struct lyd_ctx *)lydctx)->data_ctx->ctx); \
if ((r != LY_EVALID) || !lydctx || !(lydctx->val_opts & LYD_VALIDATE_MULTI_ERROR) || \
(__eitem->vecode == LYVE_SYNTAX)) { \
!__eitem || (__eitem->vecode == LYVE_SYNTAX)) { \
goto label; \
} \
}
Expand Down
6 changes: 5 additions & 1 deletion src/plugins_types/xpath1.0.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,11 @@ lyplg_type_validate_tree_xpath10(const struct ly_ctx *UNUSED(ctx), const struct
ly_err_new_no_mem(err);
} else if (ret) {
eitem = ly_err_last(LYD_CTX(ctx_node));
ly_err_new(err, ret, LYVE_DATA, eitem->data_path, NULL, "%s", eitem->msg);
if (eitem) {
ly_err_new(err, ret, LYVE_DATA, eitem->data_path, NULL, "%s", eitem->msg);
} else {
ly_err_new(err, ret, LYVE_DATA, NULL, NULL, "Failed to get the schema-mount prefix mappings.");
}
}
return ret;
}
Expand Down
5 changes: 2 additions & 3 deletions src/tree_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,8 @@ lyd_parse(const struct ly_ctx *ctx, struct lyd_node *parent, struct lyd_node **f
}

eitem = ly_err_last(ctx);
assert(eitem);
if (eitem->vecode == LYVE_SYNTAX) {
/* cannot get more errors on a syntax error */
if (!eitem || (eitem->vecode == LYVE_SYNTAX)) {
/* cannot get more errors on a syntax error or without the stored error */
goto cleanup;
}
}
Expand Down
9 changes: 9 additions & 0 deletions tests/utests/data/test_parser_xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ test_leaf(void **state)
const char *data = "<foo xmlns=\"urn:tests:a\">foo value</foo>";
struct lyd_node *tree;
struct lyd_node_term *leaf;
uint32_t prev_lo;

assert_non_null(ly_ctx_load_module(UTEST_LYCTX, "ietf-netconf-with-defaults", "2011-06-01", NULL));

Expand Down Expand Up @@ -118,6 +119,14 @@ test_leaf(void **state)
data = "<l1 xmlns=\"urn:tests:a\"><a>val-a</a><b>val-b</b><c>1</c><cont><e>0</e></cont></l1>";
PARSER_CHECK_ERROR(data, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
"Invalid boolean value \"0\".", "/a:l1[a='val-a'][b='val-b'][c='1']/cont/e", 1);

/* invalid value with multiple errors allowed while the errors are not stored */
data = "<foo3 xmlns=\"urn:tests:a\">x</foo3>";
prev_lo = ly_log_options(LY_LOLOG);
assert_int_equal(LY_EVALID, lyd_parse_data_mem(UTEST_LYCTX, data, LYD_XML, 0,
LYD_VALIDATE_PRESENT | LYD_VALIDATE_MULTI_ERROR, &tree));
ly_log_options(prev_lo);
assert_null(tree);
}

static void
Expand Down