From 82eefd6de0852d5ec93771fb06786cdc8fd8ed6f Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 8 Jan 2021 22:17:30 -0800 Subject: [PATCH] spv-legacy-decoder: Initialize all members for SPV_VALUE_TEXT. These were supposed to always be nonnull but this code didn't do it properly. --- src/output/pivot-table.h | 4 ++++ src/output/spv/spv-legacy-decoder.c | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/output/pivot-table.h b/src/output/pivot-table.h index e7537e781b..85aef6ab3c 100644 --- a/src/output/pivot-table.h +++ b/src/output/pivot-table.h @@ -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; diff --git a/src/output/spv/spv-legacy-decoder.c b/src/output/spv/spv-legacy-decoder.c index 78b1780b17..0b224405b7 100644 --- a/src/output/spv/spv-legacy-decoder.c +++ b/src/output/spv/spv-legacy-decoder.c @@ -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; } -- 2.30.2