gnumeric r16358 - branches/gnumeric-1-8/plugins/excel
- From: mortenw svn gnome org
- To: svn-commits-list gnome org
- Subject: gnumeric r16358 - branches/gnumeric-1-8/plugins/excel
- Date: Fri, 8 Feb 2008 04:21:19 +0000 (GMT)
Author: mortenw
Date: Fri Feb 8 04:21:18 2008
New Revision: 16358
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16358&view=rev
Log:
2008-02-07 Morten Welinder <terra gnome org>
* ms-biff.c (ms_biff_query_bound_check): Return (guint32)-1 on
error so we can tell.
* ms-excel-read.c (gnm_xl_importer_free): Be more careful when
freeing sst.
(sst_read_string): Be more careful. This code is a mess.
Modified:
branches/gnumeric-1-8/plugins/excel/ChangeLog
branches/gnumeric-1-8/plugins/excel/ms-biff.c
branches/gnumeric-1-8/plugins/excel/ms-excel-read.c
Modified: branches/gnumeric-1-8/plugins/excel/ms-biff.c
==============================================================================
--- branches/gnumeric-1-8/plugins/excel/ms-biff.c (original)
+++ branches/gnumeric-1-8/plugins/excel/ms-biff.c Fri Feb 8 04:21:18 2008
@@ -69,7 +69,7 @@
opcode != BIFF_CONTINUE ||
!ms_biff_query_next (q)) {
g_warning ("missing CONTINUE");
- return 0;
+ return (guint32)-1;
}
}
Modified: branches/gnumeric-1-8/plugins/excel/ms-excel-read.c
==============================================================================
--- branches/gnumeric-1-8/plugins/excel/ms-excel-read.c (original)
+++ branches/gnumeric-1-8/plugins/excel/ms-excel-read.c Fri Feb 8 04:21:18 2008
@@ -1112,11 +1112,17 @@
char *str, *old_res, *res_str = NULL;
offset = ms_biff_query_bound_check (q, offset, 2);
+ if (offset == (guint32)-1)
+ return offset;
XL_CHECK_CONDITION_VAL (offset < q->length, offset);
total_len = GSF_LE_GET_GUINT16 (q->data + offset);
offset += 2;
do {
offset = ms_biff_query_bound_check (q, offset, 1);
+ if (offset == (guint32)-1) {
+ g_free (res_str);
+ return offset;
+ }
offset += excel_read_string_header
(q->data + offset, q->length - offset,
&use_utf16, &n_markup, &has_extended,
@@ -1150,6 +1156,10 @@
txo_run.first = 0;
for (i = total_n_markup ; i-- > 0 ; offset += 4) {
offset = ms_biff_query_bound_check (q, offset, 4);
+ if (offset == (guint32)-1) {
+ g_free (res_str);
+ return offset;
+ }
if ((q->length - offset) >= 4) {
txo_run.last = g_utf8_offset_to_pointer (res_str,
GSF_LE_GET_GUINT16 (q->data+offset)) - res_str;
@@ -1197,6 +1207,8 @@
offset = 8;
for (i = 0; i < importer->sst_len; i++) {
offset = sst_read_string (q, &importer->container, importer->sst + i, offset);
+ if (offset == (guint32)-1)
+ break;
if (importer->sst[i].content == NULL)
d (4, fprintf (stderr,"Blank string in table at 0x%x.\n", i););
@@ -3070,7 +3082,8 @@
if (importer->sst != NULL) {
unsigned i = importer->sst_len;
while (i-- > 0) {
- gnm_string_unref (importer->sst[i].content);
+ if (importer->sst[i].content)
+ gnm_string_unref (importer->sst[i].content);
if (importer->sst[i].markup != NULL)
go_format_unref (importer->sst[i].markup);
}
@@ -6510,6 +6523,17 @@
g_printerr ("Unknown BOF (%x)\n", ver->type);
}
+static void
+excel_read_CODEPAGE (BiffQuery *q, GnmXLImporter *importer)
+{
+ /* This seems to appear within a workbook */
+ /* MW: And on Excel seems to drive the display
+ of currency amounts. */
+ XL_CHECK_CONDITION (q->length >= 2);
+ gnm_xl_importer_set_codepage (importer,
+ GSF_LE_GET_GUINT16 (q->data));
+}
+
void
excel_read_workbook (IOContext *context, WorkbookView *wb_view, GsfInput *input,
gboolean *is_double_stream_file)
@@ -6586,12 +6610,8 @@
case BIFF_BACKUP: break;
case BIFF_CODEPAGE: /* DUPLICATE 42 */
- /* This seems to appear within a workbook */
- /* MW: And on Excel seems to drive the display
- of currency amounts. */
- gnm_xl_importer_set_codepage (importer,
- GSF_LE_GET_GUINT16 (q->data));
- break;
+ excel_read_CODEPAGE (q, importer);
+ break;
case BIFF_OBJPROTECT:
case BIFF_PROTECT:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]