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);
 
diff --git a/src/parser_xml.c b/src/parser_xml.c
index 93d2e84..3ea3684 100644
--- a/src/parser_xml.c
+++ b/src/parser_xml.c
@@ -845,8 +845,8 @@
         LY_CHECK_ERR_GOTO(r, rc = r, 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);
 
diff --git a/tests/utests/data/test_validation.c b/tests/utests/data/test_validation.c
index d02dcc4..d0dcae5 100644
--- a/tests/utests/data/test_validation.c
+++ b/tests/utests/data/test_validation.c
@@ -1202,8 +1202,6 @@
     CHECK_LOG_CTX_APPTAG("Too few \"ll\" instances.", "Schema location \"/ii:cont/ll\".", "too-few-elements");
     CHECK_LOG_CTX_APPTAG("l leaf is not left", "Data location \"/ii:cont/l3\".", "not-left");
     CHECK_LOG_CTX_APPTAG("Must condition \"../l = 'right'\" not satisfied.", "Data location \"/ii:cont/l2\".", "must-violation");
-    CHECK_LOG_CTX_APPTAG("Duplicate instance of \"l\".", "Data location \"/ii:cont/l\", line number 7.", NULL);
-    CHECK_LOG_CTX_APPTAG("Duplicate instance of \"l\".", "Data location \"/ii:cont/l\", line number 7.", NULL);
     CHECK_LOG_CTX_APPTAG("Invalid type uint32 value \"ahoy\".", "Data location \"/ii:cont/ll\", line number 6.", NULL);
 
     /* json */
@@ -1220,8 +1218,6 @@
     CHECK_LOG_CTX_APPTAG("Too few \"ll\" instances.", "Schema location \"/ii:cont/ll\".", "too-few-elements");
     CHECK_LOG_CTX_APPTAG("l leaf is not left", "Data location \"/ii:cont/l3\".", "not-left");
     CHECK_LOG_CTX_APPTAG("Must condition \"../l = 'right'\" not satisfied.", "Data location \"/ii:cont/l2\".", "must-violation");
-    CHECK_LOG_CTX_APPTAG("Duplicate instance of \"l\".", "Data location \"/ii:cont/l\", line number 9.", NULL);
-    CHECK_LOG_CTX_APPTAG("Duplicate instance of \"l\".", "Data location \"/ii:cont/l\", line number 9.", NULL);
     CHECK_LOG_CTX_APPTAG("Invalid non-number-encoded uint32 value \"ahoy\".", "Data location \"/ii:cont/ll\", line number 7.", NULL);
 
     /* validation */