[gnumeric] Don't crash when exchanging missing axes. [#702126]



commit 3674e48ad0ab972121b268cdc850525ed4f4985f
Author: Jean Brefort <jean brefort normalesup org>
Date:   Thu Jun 13 11:12:16 2013 +0200

    Don't crash when exchanging missing axes. [#702126]

 NEWS                     |    1 +
 plugins/excel/ChangeLog  |    4 ++++
 plugins/excel/ms-chart.c |   27 +++++++++++++++------------
 3 files changed, 20 insertions(+), 12 deletions(-)
---
diff --git a/NEWS b/NEWS
index f92da51..b8a19fe 100644
--- a/NEWS
+++ b/NEWS
@@ -31,6 +31,7 @@ Dmitry Smirnov:
 Jean:
        * Adjust labels vertical alignment in document properties
          dialog. [#700156]
+       * Don't crash when exchanging missing axes. [#702126]
 
 Morten:
        * Improve xlsx import of style-only cells.
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 55acc9e..ecb4747 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,7 @@
+2013-06-13  Jean Brefort  <jean brefort normalesup org>
+
+       * ms-chart.c (end): don't crash when exchanging missing axes. [#702126]
+
 2013-06-12  Andreas J. Guelzow <aguelzow pyrshep ca>
 
        * xlsx-write.c (xlsx_write_print_info): fix typo
diff --git a/plugins/excel/ms-chart.c b/plugins/excel/ms-chart.c
index 1030334..8bdb65c 100644
--- a/plugins/excel/ms-chart.c
+++ b/plugins/excel/ms-chart.c
@@ -3014,18 +3014,21 @@ not_a_matrix:
                                GogAxis *y = gog_plot_get_axis (s->plot, GOG_AXIS_Y);
                                GOStyle *x_style, *y_style;
                                int i;
-                               for (i = 0 ; i < GOG_AXIS_ELEM_MAX_ENTRY ; i++)
-                                       xl_axis_swap_elem (x, y, i);
-                               g_object_get (G_OBJECT (x), "style", &x_style, NULL);
-                               g_object_get (G_OBJECT (y), "style", &y_style, NULL);
-                               g_object_set (G_OBJECT (y), "style", x_style, NULL);
-                               g_object_set (G_OBJECT (x), "style", y_style, NULL);
-                               g_object_unref (x_style);
-                               g_object_unref (y_style);
-                               /* we must also exchange children */
-                               object_swap_children (GOG_OBJECT (x), GOG_OBJECT (y), "Label");
-                               object_swap_children (GOG_OBJECT (x), GOG_OBJECT (y), "MajorGrid");
-                               object_swap_children (GOG_OBJECT (x), GOG_OBJECT (y), "MinorGrid");
+                               if (x != NULL && y!= NULL) {
+                                       /* we only execute that code if both axes really exist, see #702126 */
+                                       for (i = 0 ; i < GOG_AXIS_ELEM_MAX_ENTRY ; i++)
+                                               xl_axis_swap_elem (x, y, i);
+                                       g_object_get (G_OBJECT (x), "style", &x_style, NULL);
+                                       g_object_get (G_OBJECT (y), "style", &y_style, NULL);
+                                       g_object_set (G_OBJECT (y), "style", x_style, NULL);
+                                       g_object_set (G_OBJECT (x), "style", y_style, NULL);
+                                       g_object_unref (x_style);
+                                       g_object_unref (y_style);
+                                       /* we must also exchange children */
+                                       object_swap_children (GOG_OBJECT (x), GOG_OBJECT (y), "Label");
+                                       object_swap_children (GOG_OBJECT (x), GOG_OBJECT (y), "MajorGrid");
+                                       object_swap_children (GOG_OBJECT (x), GOG_OBJECT (y), "MinorGrid");
+                               }
                        }
                }
                if (g_slist_length (s->plot->series) == 0) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]