diff --git a/src/util/virxml.c b/src/util/virxml.c index 51173303fe..38baeec5bb 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -1047,6 +1047,11 @@ catchXMLError(void *ctx, const char *msg G_GNUC_UNUSED, ...) cur = ctxt->input->cur; base = ctxt->input->base; + /* skip backwards over NUL terminator, in case we failed + * parsing at the EOF position */ + if ((cur > base) && *cur == '\0') + cur--; + /* skip backwards over any end-of-lines */ while ((cur > base) && ((*(cur) == '\n') || (*(cur) == '\r'))) cur--; diff --git a/tests/qemuxmlconfdata/broken-xml-invalid.x86_64-latest.err b/tests/qemuxmlconfdata/broken-xml-invalid.x86_64-latest.err index 35a1801371..a3bacd5d3a 100644 --- a/tests/qemuxmlconfdata/broken-xml-invalid.x86_64-latest.err +++ b/tests/qemuxmlconfdata/broken-xml-invalid.x86_64-latest.err @@ -1,3 +1,3 @@ ABS_SRCDIR/qemuxmlconfdata/broken-xml-invalid.xml:2: Couldn't find end of Start Tag dom line 1 -(null) -^ +