When printing an XML related error, guard against NULL pointers getting passed to our error stream

This commit is contained in:
John Emmas 2015-07-23 17:52:42 +01:00
parent cf5a8651d8
commit a7508a9cf0
1 changed files with 10 additions and 4 deletions

View File

@ -203,13 +203,19 @@ static void
libxml_structured_error_func (void* /* parsing_context*/,
xmlErrorPtr err)
{
string msg = err->message;
string msg;
if (err->message)
msg = err->message;
replace_all (msg, "\n", "");
error << X_("XML error: ") << msg << " in " << err->file << " at line " << err->line;
if (err->int2) {
error << ':' << err->int2;
if (err->file && err->line) {
error << X_("XML error: ") << msg << " in " << err->file << " at line " << err->line;
if (err->int2) {
error << ':' << err->int2;
}
}
error << endmsg;
}