spv_item_get_table() returns a borrowed reference, but read_spv_file()
treated it as if it owned it. This fixes the problem.
This fixes crashes opening .spv files in PSPPIRE with File|Open.
Also, change spv_item_get_table() to return a const pointer, to make it
clearer that the reference is a borrowed one.
return error;
}
-struct pivot_table *
+const struct pivot_table *
spv_item_get_table (const struct spv_item *item_)
{
struct spv_item *item = CONST_CAST (struct spv_item *, item_);
(We can't just set item->table_look because light tables ignore it and
legacy tables sometimes override it.) */
if (spv_item_is_table (item))
- pivot_table_set_look (spv_item_get_table (item), look);
+ {
+ spv_item_load (item);
+ pivot_table_set_look (item->table, look);
+ }
for (size_t i = 0; i < item->n_children; i++)
spv_item_set_table_look (item->children[i], look);
struct spv_item *spv_item_get_child (const struct spv_item *, size_t idx);
bool spv_item_is_table (const struct spv_item *);
-struct pivot_table *spv_item_get_table (const struct spv_item *);
+const struct pivot_table *spv_item_get_table (const struct spv_item *);
bool spv_item_is_text (const struct spv_item *);
const struct pivot_value *spv_item_get_text (const struct spv_item *);
if (items[i]->type == SPV_ITEM_TEXT)
spv_text_submit (items[i]);
else if (items[i]->type == SPV_ITEM_TABLE)
- pivot_table_submit (spv_item_get_table (items[i]));
+ pivot_table_submit (pivot_table_ref (spv_item_get_table (items[i])));
prev_heading = heading;
}
dump_heading_transition (prev_heading, spv_get_root (spv));