SHOW: Fix crash in SHOW TITLE and SHOW SUBTITLE if there is no (sub)title.
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 14 Apr 2024 16:48:23 +0000 (09:48 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 14 Apr 2024 16:48:32 +0000 (09:48 -0700)
Thanks to Zhou Geng for reporting this bug as poc14 in the report here:
https://lists.gnu.org/archive/html/bug-gnu-pspp/2024-03/msg00015.html

src/language/commands/set.c

index c1792337b876fd2e865ee592104549b1cc8f0989..bca5521f4ddc7a383033e5501013a4796c7a1a3a 100644 (file)
@@ -1028,7 +1028,7 @@ show_SPLIT (const struct dataset *ds)
 static char *
 show_SUBTITLE (const struct dataset *ds UNUSED)
 {
-  return xstrdup (output_get_subtitle ());
+  return xstrdup_if_nonnull (output_get_subtitle ());
 }
 
 static char *
@@ -1040,7 +1040,7 @@ show_TEMPDIR (const struct dataset *ds UNUSED)
 static char *
 show_TITLE (const struct dataset *ds UNUSED)
 {
-  return xstrdup (output_get_title ());
+  return xstrdup_if_nonnull (output_get_title ());
 }
 
 static bool