parser xml BUGFIX check for empty input
Refs cesnet/netopeer2#1201
diff --git a/src/parser_xml.c b/src/parser_xml.c
index 1f395b8..5e9d5c3 100644
--- a/src/parser_xml.c
+++ b/src/parser_xml.c
@@ -979,6 +979,12 @@
assert(envp && !*envp);
+ if (xmlctx->status != LYXML_ELEMENT) {
+ /* nothing to parse */
+ assert(xmlctx->status == LYXML_END);
+ goto cleanup;
+ }
+
/* parse "rpc" */
r = lydxml_envelope(xmlctx, "rpc", "urn:ietf:params:xml:ns:netconf:base:1.0", 0, envp);
LY_CHECK_ERR_GOTO(r, rc = r, cleanup);
@@ -1027,6 +1033,12 @@
assert(envp && !*envp);
+ if (xmlctx->status != LYXML_ELEMENT) {
+ /* nothing to parse */
+ assert(xmlctx->status == LYXML_END);
+ goto cleanup;
+ }
+
/* parse "notification" */
r = lydxml_envelope(xmlctx, "notification", "urn:ietf:params:xml:ns:netconf:notification:1.0", 0, envp);
LY_CHECK_ERR_GOTO(r, rc = r, cleanup);
@@ -1453,6 +1465,12 @@
assert(envp && !*envp);
+ if (xmlctx->status != LYXML_ELEMENT) {
+ /* nothing to parse */
+ assert(xmlctx->status == LYXML_END);
+ goto cleanup;
+ }
+
/* parse "rpc-reply" */
r = lydxml_envelope(xmlctx, "rpc-reply", "urn:ietf:params:xml:ns:netconf:base:1.0", 0, envp);
LY_CHECK_ERR_GOTO(r, rc = r, cleanup);