message: check if location is present before accessing it
authorFriedrich Beckmann <friedrich.beckmann@gmx.de>
Fri, 22 Nov 2024 13:21:27 +0000 (14:21 +0100)
committerFriedrich Beckmann <friedrich.beckmann@gmx.de>
Fri, 22 Nov 2024 13:21:27 +0000 (14:21 +0100)
The message location is accessed without checking if the
location is actually present. I added a check if the message
location is there. Thanks to Simon Jacobs for reporting the
bug!

Closes: https://savannah.gnu.org/bugs/?66239
src/libpspp/message.c

index 9b20a2350d9c7e21be0a0790917f0a20e658c62a..7bc44f69089546d1c0941ffd9bb2290d5596d1ff 100644 (file)
@@ -399,7 +399,7 @@ msg_to_string (const struct msg *m)
   ds_put_cstr (&s, m->text);
 
   const struct msg_location *loc = m->location;
-  if (m->category != MSG_C_GENERAL
+  if (m->category != MSG_C_GENERAL && !msg_location_is_empty(loc)
       && loc->src && loc->start.line && loc->start.column
       && msg_handler.lex_source_get_line)
     {