[gnumeric] Fuzzed file fix. [751270]



commit 488b9fbb1488c224a8de4922c479b23a702d6ec5
Author: Jean Brefort <jean brefort normalesup org>
Date:   Mon Jun 22 08:41:43 2015 +0200

    Fuzzed file fix. [751270]

 NEWS                     |    2 +-
 plugins/excel/ChangeLog  |    4 ++
 plugins/excel/ms-chart.c |   97 +++++++++++++++++++++++++--------------------
 3 files changed, 59 insertions(+), 44 deletions(-)
---
diff --git a/NEWS b/NEWS
index 526940a..6caea89 100644
--- a/NEWS
+++ b/NEWS
@@ -14,7 +14,7 @@ Andreas:
 Jean:
        * Fix xlsx import of plot area manual layout. [#748016]
        * Fix out of bounds read. [#749121]
-       * Fuzzed file fixes.  [#750042]
+       * Fuzzed file fixes.  [#750042] [#751270]
 
 Morten:
        * Fix import/export of graph backplane.
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 621299a..f9fe655 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,7 @@
+2015-06-22  Jean Brefort  <jean brefort normalesup org>
+
+       * ms-chart.c (end): skip NULL excel series. [#751270]
+
 2015-06-21  Jean Brefort  <jean brefort normalesup org>
 
        * ms-chart.c (ms_excel_chart_read): initialize XLChartReadState::is_contour.
diff --git a/plugins/excel/ms-chart.c b/plugins/excel/ms-chart.c
index 9ff4423..043fb60 100644
--- a/plugins/excel/ms-chart.c
+++ b/plugins/excel/ms-chart.c
@@ -2876,7 +2876,7 @@ not_a_matrix:
 
                if (!s->is_surface) {
                        unsigned k = 0, l = s->series->len, added_plots = 0, n;
-                       if (s->dropbar) {
+                       if (l > 0 && s->dropbar) {
                                GogObject *plot = GOG_OBJECT (gog_plot_new_by_name ("GogDropBarPlot"));
                                if (s->has_extra_dataformat){
                                        g_object_set (G_OBJECT (plot), "plot-group", "GogStockPlot", NULL);
@@ -2884,31 +2884,38 @@ not_a_matrix:
                                l--;
                                while (eseries = g_ptr_array_index (s->series, l),
                                                        eseries->chart_group != s->plot_counter)
-                                       l--;
+                                       if (l != 0)
+                                               l--;
+                                       else
+                                               eseries = NULL;
                                gog_object_add_by_name (GOG_OBJECT (s->chart), "Plot", plot);
                                gog_object_reorder (plot, TRUE, FALSE);
                                added_plots++;
                                series = gog_plot_new_series (GOG_PLOT (plot));
                                g_object_set (plot, "gap_percentage", s->dropbar_width, NULL);
-                               if (eseries->data [GOG_MS_DIM_CATEGORIES].data != NULL) {
-                                       gog_series_set_XL_dim (series, GOG_MS_DIM_CATEGORIES,
-                                               eseries->data [GOG_MS_DIM_CATEGORIES].data, NULL);
-                                       eseries->data [GOG_MS_DIM_CATEGORIES].data = NULL;
+                               if (eseries) {
+                                       if (eseries->data [GOG_MS_DIM_CATEGORIES].data != NULL) {
+                                               gog_series_set_XL_dim (series, GOG_MS_DIM_CATEGORIES,
+                                                       eseries->data [GOG_MS_DIM_CATEGORIES].data, NULL);
+                                               eseries->data [GOG_MS_DIM_CATEGORIES].data = NULL;
+                                       }
+                                       if (eseries->data [GOG_MS_DIM_VALUES].data != NULL) {
+                                               gog_series_set_XL_dim (series, GOG_MS_DIM_END,
+                                                       eseries->data [GOG_MS_DIM_VALUES].data, NULL);
+                                               eseries->data [GOG_MS_DIM_VALUES].data = NULL;
+                                       } else
+                                               eseries->extra_dim = GOG_MS_DIM_END;
                                }
-                               if (eseries->data [GOG_MS_DIM_VALUES].data != NULL) {
-                                       gog_series_set_XL_dim (series, GOG_MS_DIM_END,
-                                               eseries->data [GOG_MS_DIM_VALUES].data, NULL);
-                                       eseries->data [GOG_MS_DIM_VALUES].data = NULL;
-                               } else
-                                       eseries->extra_dim = GOG_MS_DIM_END;
                                while (eseries = g_ptr_array_index (s->series, k++),
-                                                       eseries->chart_group != s->plot_counter);
-                               if (eseries->data [GOG_MS_DIM_VALUES].data != NULL) {
-                                       gog_series_set_XL_dim (series, GOG_MS_DIM_START,
-                                               eseries->data [GOG_MS_DIM_VALUES].data, NULL);
-                                       eseries->data [GOG_MS_DIM_VALUES].data = NULL;
-                               } else
-                                       eseries->extra_dim = GOG_MS_DIM_START;
+                                                       eseries && eseries->chart_group != s->plot_counter);
+                               if (eseries) {
+                                       if (eseries->data [GOG_MS_DIM_VALUES].data != NULL) {
+                                               gog_series_set_XL_dim (series, GOG_MS_DIM_START,
+                                                       eseries->data [GOG_MS_DIM_VALUES].data, NULL);
+                                               eseries->data [GOG_MS_DIM_VALUES].data = NULL;
+                                       } else
+                                               eseries->extra_dim = GOG_MS_DIM_START;
+                               }
                                g_object_set (G_OBJECT (series),
                                        "style", s->dropbar_style,
                                        NULL);
@@ -2926,32 +2933,36 @@ not_a_matrix:
                                        gog_object_reorder (plot, TRUE, FALSE);
                                series = gog_plot_new_series (GOG_PLOT (plot));
                                while (eseries = g_ptr_array_index (s->series, k++),
-                                                       eseries->chart_group != s->plot_counter);
-                               if (eseries->data [GOG_MS_DIM_CATEGORIES].data != NULL) {
-                                       gog_series_set_XL_dim (series, GOG_MS_DIM_CATEGORIES,
-                                               eseries->data [GOG_MS_DIM_CATEGORIES].data, NULL);
-                                       eseries->data [GOG_MS_DIM_CATEGORIES].data = NULL;
+                                                       eseries && eseries->chart_group != s->plot_counter);
+                               if (eseries != NULL) {
+                                       if (eseries->data [GOG_MS_DIM_CATEGORIES].data != NULL) {
+                                               gog_series_set_XL_dim (series, GOG_MS_DIM_CATEGORIES,
+                                                       eseries->data [GOG_MS_DIM_CATEGORIES].data, NULL);
+                                               eseries->data [GOG_MS_DIM_CATEGORIES].data = NULL;
+                                       }
+                                       if (eseries->data [GOG_MS_DIM_VALUES].data != NULL) {
+                                               gog_series_set_XL_dim (series, GOG_MS_DIM_HIGH,
+                                                       eseries->data [GOG_MS_DIM_VALUES].data, NULL);
+                                               eseries->data [GOG_MS_DIM_VALUES].data = NULL;
+                                       } else
+                                               eseries->extra_dim = GOG_MS_DIM_HIGH;
                                }
-                               if (eseries->data [GOG_MS_DIM_VALUES].data != NULL) {
-                                       gog_series_set_XL_dim (series, GOG_MS_DIM_HIGH,
-                                               eseries->data [GOG_MS_DIM_VALUES].data, NULL);
-                                       eseries->data [GOG_MS_DIM_VALUES].data = NULL;
-                               } else
-                                       eseries->extra_dim = GOG_MS_DIM_HIGH;
                                while (eseries = g_ptr_array_index (s->series, k++),
-                                                       eseries->chart_group != s->plot_counter);
-                               if (eseries->data [GOG_MS_DIM_VALUES].data != NULL) {
-                                       gog_series_set_XL_dim (series, GOG_MS_DIM_LOW,
-                                               eseries->data [GOG_MS_DIM_VALUES].data, NULL);
-                                       eseries->data [GOG_MS_DIM_VALUES].data = NULL;
-                               } else
-                                       eseries->extra_dim = GOG_MS_DIM_LOW;
-                               if (s->chartline_style[1]) {
-                                       g_object_set (G_OBJECT (series),
-                                                     "style", s->chartline_style[1],
-                                                     NULL);
-                                       g_object_unref (s->chartline_style[1]);
-                                       s->chartline_style[1] = NULL;
+                                                       eseries && eseries->chart_group != s->plot_counter);
+                               if (eseries != NULL) {
+                                       if (eseries->data [GOG_MS_DIM_VALUES].data != NULL) {
+                                               gog_series_set_XL_dim (series, GOG_MS_DIM_LOW,
+                                                       eseries->data [GOG_MS_DIM_VALUES].data, NULL);
+                                               eseries->data [GOG_MS_DIM_VALUES].data = NULL;
+                                       } else
+                                               eseries->extra_dim = GOG_MS_DIM_LOW;
+                                       if (s->chartline_style[1]) {
+                                               g_object_set (G_OBJECT (series),
+                                                                 "style", s->chartline_style[1],
+                                                                 NULL);
+                                               g_object_unref (s->chartline_style[1]);
+                                               s->chartline_style[1] = NULL;
+                                       }
                                }
                        }
                        for (i = k ; i < l; i++ ) {


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