When logging XML error messages, make sure we don't accidentally log an empty message
authorJohn Emmas <johne53@tiscali.co.uk>
Thu, 21 Apr 2016 15:45:15 +0000 (16:45 +0100)
committerJohn Emmas <johne53@tiscali.co.uk>
Thu, 21 Apr 2016 15:45:15 +0000 (16:45 +0100)
Amends my previous commit #a7508a9c from 23rd July 2015. If the filename and/or line number were NULL, we could end up logging a message with no text!

gtk2_ardour/ardour_ui.cc

index d221db743ccfe6faabbac92818e9a4494a94e2d1..ea0586f5cea82be260fc964abe2d40035ab15540 100644 (file)
@@ -226,14 +226,19 @@ libxml_structured_error_func (void* /* parsing_context*/,
 
        replace_all (msg, "\n", "");
 
-       if (err->file && err->line) {
-               error << X_("XML error: ") << msg << " in " << err->file << " at line " << err->line;
+       if (!msg.empty()) {
+               if (err->file && err->line) {
+                       error << X_("XML error: ") << msg << " in " << err->file << " at line " << err->line;
 
-               if (err->int2) {
-                       error << ':' << err->int2;
+                       if (err->int2) {
+                               error << ':' << err->int2;
+                       }
+
+                       error << endmsg;
+               } else {
+                       error << msg << endmsg;
                }
        }
-       error << endmsg;
 }