parser BUGFIX stack-oveflow protection
In yang/json format by tracking the right and left braces.
In xml by tracking open and close element.
diff --git a/src/xml.c b/src/xml.c
index ac1655b..907058d 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -598,7 +598,14 @@
e->prefix = prefix;
e->name_len = name_len;
e->prefix_len = prefix_len;
+
LY_CHECK_RET(ly_set_add(&xmlctx->elements, e, 1, NULL));
+ if (xmlctx->elements.count > LY_MAX_BLOCK_DEPTH) {
+ LOGERR(xmlctx->ctx, LY_EINVAL,
+ "The maximum number of open elements has been exceeded.");
+ ret = LY_EINVAL;
+ goto cleanup;
+ }
/* skip WS */
ign_xmlws(xmlctx);