spv-legacy-decoder: Initialize all members for SPV_VALUE_TEXT.
authorBen Pfaff <blp@cs.stanford.edu>
Sat, 9 Jan 2021 06:17:30 +0000 (22:17 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Sat, 9 Jan 2021 06:17:30 +0000 (22:17 -0800)
These were supposed to always be nonnull but this code didn't do it
properly.

src/output/pivot-table.h
src/output/spv/spv-legacy-decoder.c

index e7537e781bc52574affc49500bdf002afa007a57..85aef6ab3cafa76531c87bb3bd50c875db095746 100644 (file)
@@ -688,6 +688,8 @@ struct pivot_value
         /* PIVOT_VALUE_TEXT. */
         struct
           {
+            /* 'local', 'c', and 'id' must all be nonnull, but they are allowed
+               to be the same pointer. */
             char *local;              /* Localized. */
             char *c;                  /* English. */
             char *id;                 /* Identifier. */
@@ -698,6 +700,8 @@ struct pivot_value
         /* PIVOT_VALUE_TEMPLATE. */
         struct
           {
+            /* Both 'local' and 'id' must be nonnull, but they are allowed to
+               be the same pointer. */
             char *local;              /* Localized. */
             char *id;                 /* Identifier. */
             struct pivot_argument *args;
index 78b1780b1748b5a3a2fdca15c06d19dd3c810b89..0b224405b7913a297f5236144d4ad804ae4e1edd 100644 (file)
@@ -720,6 +720,9 @@ decode_label_frame (struct pivot_table *table,
               value->text.local = new;
             }
         }
+      if (!value->text.local)
+        value->text.local = xstrdup ("");
+      value->text.c = value->text.id = value->text.local;
       pivot_value_destroy (*target);
       *target = value;
     }