pivot-table: Tolerate nulls in pivot_value_clone().
authorBen Pfaff <blp@cs.stanford.edu>
Sat, 9 Jan 2021 06:18:12 +0000 (22:18 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Sat, 9 Jan 2021 06:18:12 +0000 (22:18 -0800)
These members should not be null, but there is little cost and perhaps some
benefit in allowing it.

src/output/pivot-table.c

index 01a4a859f159a93b6b70c2aed48123fa36985a3b..aa3b9b51c25b28185c2132ecd875cf403e4497d6 100644 (file)
@@ -2483,10 +2483,10 @@ pivot_value_clone (const struct pivot_value *old)
     case PIVOT_VALUE_TEXT:
       new->text.local = xstrdup (old->text.local);
       new->text.c = (old->text.c == old->text.local ? new->text.local
-                     : xstrdup (old->text.c));
+                     : xstrdup_if_nonnull (old->text.c));
       new->text.id = (old->text.id == old->text.local ? new->text.local
                       : old->text.id == old->text.c ? new->text.c
-                      : xstrdup (old->text.id));
+                      : xstrdup_if_nonnull (old->text.id));
       break;
 
     case PIVOT_VALUE_TEMPLATE: