X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fods-reader.c;h=cb16dbc6944187ea0312fe82f135c85623ea02df;hb=36e1a0b66c81e1f2a8b5633c4fac259ffb046c98;hp=2b830fa2e6a8bf066d6ce1a0c7c1091aa06b96cb;hpb=e683e938fb5fd83be9c7fcf1ae85cf4546ac904e;p=pspp diff --git a/src/data/ods-reader.c b/src/data/ods-reader.c index 2b830fa2e6..cb16dbc694 100644 --- a/src/data/ods-reader.c +++ b/src/data/ods-reader.c @@ -523,6 +523,8 @@ init_reader (struct ods_reader *r, bool report_errors) zip_member_ref (content); + if (r->xtr) + xmlFreeTextReader (r->xtr); xtr = xmlReaderForIO ((xmlInputReadCallback) zip_member_read, (xmlInputCloseCallback) zip_member_finish, @@ -534,6 +536,10 @@ init_reader (struct ods_reader *r, bool report_errors) r->xtr = xtr; r->spreadsheet.type = SPREADSHEET_ODS; + r->row = 0; + r->col = 0; + r->current_sheet = 0; + r->state = STATE_INIT; if (report_errors) xmlTextReaderSetErrorHandler (xtr, ods_error_handler, r); @@ -693,7 +699,7 @@ ods_make_reader (struct spreadsheet *spreadsheet, /* xrealloc (unlike realloc) doesn't initialise its memory to 0 */ memset (var_spec + n_var_specs, 0, - (n_var_specs - idx + 1) * sizeof (*var_spec)); + (idx - n_var_specs + 1) * sizeof (*var_spec)); n_var_specs = idx + 1; } var_spec[idx].firstval.text = 0; @@ -749,6 +755,10 @@ ods_make_reader (struct spreadsheet *spreadsheet, if (idx >= n_var_specs) { var_spec = xrealloc (var_spec, sizeof (*var_spec) * (idx + 1)); + memset (var_spec + n_var_specs, + 0, + (idx - n_var_specs + 1) * sizeof (*var_spec)); + var_spec [idx].name = NULL; n_var_specs = idx + 1; } @@ -926,7 +936,7 @@ ods_file_casereader_read (struct casereader *reader UNUSED, void *r_) for (col = 0; col < r->col_span; ++col) { const struct variable *var; - const int idx = r->col + col - r->start_col - 1; + const int idx = r->col - col - r->start_col - 1; if (idx < 0) continue; if (r->stop_col != -1 && idx > r->stop_col - r->start_col )