[gnumeric] xls: fix crash on save.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] xls: fix crash on save.
- Date: Wed, 7 Mar 2012 00:28:46 +0000 (UTC)
commit 092fe3811b2c4819d82b2fd80c59cc47f2aead6b
Author: Morten Welinder <terra gnome org>
Date: Tue Mar 6 19:28:25 2012 -0500
xls: fix crash on save.
NEWS | 1 +
plugins/excel/ChangeLog | 7 +++++++
plugins/excel/ms-excel-write.c | 9 +++++----
3 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/NEWS b/NEWS
index 6c6e081..ce64aa6 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ Andreas:
Morten:
* Hook up unknown_image icon for ssconvert too.
+ * Fix xls save crash. [#671267]
--------------------------------------------------------------------------
Gnumeric 1.11.2
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 5e79a76..fe35907 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,10 @@
+2012-03-06 Morten Welinder <terra gnome org>
+
+ * ms-excel-write.c (cb_write_condition): Handle lack of style
+ conditions.
+ (excel_write_prep_conditions): Ditto.
+ (put_colors): Ditto. Fixes crash of #671267.
+
2012-03-02 Morten Welinder <terra gnome org>
* Release 1.11.2
diff --git a/plugins/excel/ms-excel-write.c b/plugins/excel/ms-excel-write.c
index e209c7b..91618fa 100644
--- a/plugins/excel/ms-excel-write.c
+++ b/plugins/excel/ms-excel-write.c
@@ -930,12 +930,13 @@ cb_write_condition (GnmStyleConditions const *sc, CondDetails *cd,
guint32 flags = 0x38C3FF; /* these are always true */
unsigned i, expr0_len, expr1_len, header_pos;
GArray const *details = gnm_style_conditions_details (sc);
+ unsigned det_len = details ? details->len : 0;
GnmStyleCond const *cond;
GnmStyle const *s;
/* The parent record */
ms_biff_put_var_next (bp, BIFF_CONDFMT);
- GSF_LE_SET_GUINT16 (buf+0, details->len);
+ GSF_LE_SET_GUINT16 (buf+0, det_len);
GSF_LE_SET_GUINT16 (buf+2, 1); /* force a redraw */
xl_le_set_range (buf+4, &cd->bb);
range_count = g_slist_length (cd->ranges);
@@ -949,7 +950,7 @@ cb_write_condition (GnmStyleConditions const *sc, CondDetails *cd,
g_slist_free (cd->ranges);
/* The individual conditions */
- for (i = 0 ; i < details->len ; i++) {
+ for (i = 0 ; i < det_len ; i++) {
cond = &g_array_index (details, GnmStyleCond, i);
s = cond->overlay;
@@ -1494,7 +1495,7 @@ excel_write_prep_conditions (ExcelWriteSheet *esheet)
continue;
conds = gnm_style_conditions_details (
gnm_style_get_conditions (sr->style));
- for (i = 0 ; i < conds->len ; i++) {
+ for (i = 0 ; i < (conds ? conds->len : 0) ; i++) {
cond = &g_array_index (conds, GnmStyleCond, i);
if (cond->texpr[0] != NULL)
excel_write_prep_expr (esheet->ewb, cond->texpr[0]);
@@ -1801,7 +1802,7 @@ put_colors (ExcelStyleVariant const *esv, gpointer dummy, XLExportBase *ewb)
NULL != gnm_style_get_conditions (st)) {
GArray const *conds = gnm_style_conditions_details (
gnm_style_get_conditions (st));
- for (i = 0 ; i < conds->len ; i++) {
+ for (i = 0 ; i < (conds ? conds->len : 0) ; i++) {
st = g_array_index (conds, GnmStyleCond, i).overlay;
if (gnm_style_is_element_set (st, MSTYLE_FONT_COLOR))
put_color_gnm (ewb, gnm_style_get_font_color (st));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]