state_data_destroy (&r->rsd);
- if ( ! r->used_first_case )
+ if (r->first_case && ! r->used_first_case )
case_unref (r->first_case);
- caseproto_unref (r->proto);
+ if (r->proto)
+ caseproto_unref (r->proto);
gnumeric_destroy (&r->spreadsheet);
}
r = (struct gnumeric_reader *) (spreadsheet);
- if (r->rsd.row != -1)
- r = gnumeric_reopen (r, NULL, true);
+ r = gnumeric_reopen (r, NULL, true);
if ( opts->cell_range )
{
r->target_sheet_index = opts->sheet_index;
r->rsd.row = r->rsd.col = -1;
r->rsd.current_sheet = -1;
+ r->first_case = NULL;
+ r->proto = NULL;
/* Advance to the start of the cells for the target sheet */
while ( (r->rsd.state != STATE_CELL || r->rsd.row < r->start_row )