Skip to content

Commit

Permalink
parser xml BUGFIX multi-error for attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
lePici authored and michalvasko committed Sep 4, 2024
1 parent 18afb71 commit f410c2e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/parser_xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ lydxml_metadata(struct lyd_xml_ctx *lydctx, const struct lysc_node *sparent, str
if (lydctx->parse_opts & LYD_PARSE_STRICT) {
LOGVAL(xmlctx->ctx, LYVE_REFERENCE, "Missing mandatory prefix for XML metadata \"%.*s\".",
(int)xmlctx->name_len, xmlctx->name);
ret = LY_EVALID;
goto cleanup;
/* If LYD_VALIDATE_MULTI_ERROR is set, then continue parsing, because otherwise the parser context
* will remain in a bad state, which will cause termination on some assert or undefined behavior.
*/
LY_DPARSER_ERR_GOTO(LY_EVALID, ret = LY_EVALID, lydctx, cleanup);
}

/* skip attr */
Expand Down Expand Up @@ -1059,14 +1061,13 @@ lydxml_subtree_r(struct lyd_xml_ctx *lydctx, struct lyd_node *parent, struct lyd
/* create metadata/attributes */
if (xmlctx->status == LYXML_ATTRIBUTE) {
if (snode) {
rc = lydxml_metadata(lydctx, snode, &meta);
LY_CHECK_GOTO(rc, cleanup);
r = lydxml_metadata(lydctx, snode, &meta);
} else {
assert(lydctx->parse_opts & LYD_PARSE_OPAQ);
rc = lydxml_attrs(xmlctx, &attr);
LY_CHECK_GOTO(rc, cleanup);
r = lydxml_attrs(xmlctx, &attr);
}
}
LY_DPARSER_ERR_GOTO(r, rc = r, lydctx, cleanup);

assert(xmlctx->status == LYXML_ELEM_CONTENT);
if (!snode) {
Expand Down

0 comments on commit f410c2e

Please sign in to comment.