parser BUGFIX skip new validation on multi-error
Because it could cause auto-deletion, which in turn
invalid memory access.
diff --git a/src/parser_json.c b/src/parser_json.c
index ccc72a4..cd1e5d1 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -1434,8 +1434,8 @@
LY_DPARSER_ERR_GOTO(r, rc = r, lydctx, cleanup);
}
- if (!(lydctx->parse_opts & LYD_PARSE_ONLY)) {
- /* new node validation, autodelete CANNOT occur, all nodes are new */
+ if (!(lydctx->parse_opts & LYD_PARSE_ONLY) && !rc) {
+ /* new node validation, autodelete CANNOT occur (it can if multi-error), all nodes are new */
r = lyd_validate_new(lyd_node_child_p(*node), snode, NULL, lydctx->val_opts, NULL);
LY_DPARSER_ERR_GOTO(r, rc = r, lydctx, cleanup);