diff --git a/src/xml.c b/src/xml.c index d59b01f57..cdd9bca00 100644 --- a/src/xml.c +++ b/src/xml.c @@ -1253,7 +1253,7 @@ lyxml_parse_mem(struct ly_ctx *ctx, const char *data, int options) repeat: /* process document */ - while (1) { + while (c) { if (!*c) { /* eof */ return first; @@ -1290,6 +1290,10 @@ lyxml_parse_mem(struct ly_ctx *ctx, const char *data, int options) } } + if (!c) { + goto error; + } + root = lyxml_parse_elem(ctx, c, &len, NULL, options); if (!root) { goto error;