As a side effect, it no longer crashes
int start_row;
int start_col;
int stop_row;
int stop_col;
int start_row;
int start_col;
int stop_row;
int stop_col;
const char *
ods_get_sheet_name (struct spreadsheet *s, int n)
{
const char *
ods_get_sheet_name (struct spreadsheet *s, int n)
{
struct ods_reader *or = (struct ods_reader *) s;
assert (n < s->n_sheets);
while (
struct ods_reader *or = (struct ods_reader *) s;
assert (n < s->n_sheets);
while (
- (or->n_allocated_sheets <= n)
- &&
- (1 == (ret = xmlTextReaderRead (or->xtr)))
+ (or->n_allocated_sheets <= n)
+ || or->state != STATE_SPREADSHEET
+ int ret = xmlTextReaderRead (or->xtr);
+ if ( ret != 1)
+ break;
+
char *
ods_get_sheet_range (struct spreadsheet *s, int n)
{
char *
ods_get_sheet_range (struct spreadsheet *s, int n)
{
struct ods_reader *or = (struct ods_reader *) s;
assert (n < s->n_sheets);
while (
struct ods_reader *or = (struct ods_reader *) s;
assert (n < s->n_sheets);
while (
(or->n_allocated_sheets <= n)
(or->n_allocated_sheets <= n)
- || (or->sheets[n].stop_row == -1) )
- &&
- (1 == (ret = xmlTextReaderRead (or->xtr)))
+ || (or->sheets[n].stop_row == -1)
+ || or->state != STATE_SPREADSHEET
+ int ret = xmlTextReaderRead (or->xtr);
+ if ( ret != 1)
+ break;
+
return create_cell_ref (
or->sheets[n].start_col,
or->sheets[n].start_row,
return create_cell_ref (
or->sheets[n].start_col,
or->sheets[n].start_row,
if (r->current_sheet >= r->n_allocated_sheets)
{
if (r->current_sheet >= r->n_allocated_sheets)
{
+ assert (r->current_sheet == r->n_allocated_sheets);
r->sheets = xrealloc (r->sheets, sizeof (*r->sheets) * ++r->n_allocated_sheets);
r->sheets[r->n_allocated_sheets - 1].start_col = -1;
r->sheets[r->n_allocated_sheets - 1].stop_col = -1;
r->sheets = xrealloc (r->sheets, sizeof (*r->sheets) * ++r->n_allocated_sheets);
r->sheets[r->n_allocated_sheets - 1].start_col = -1;
r->sheets[r->n_allocated_sheets - 1].stop_col = -1;