[goffice: 1/2] Fix crash if a XY plot series has data labels but no valid data. [#426]



commit c72c42965929a68a22678b79911b9b75286e7b53
Author: Jean Brefort <jean brefort normalesup org>
Date:   Fri Dec 13 15:02:41 2019 +0100

    Fix crash if a XY plot series has data labels but no valid data. [#426]

 ChangeLog                         | 7 +++++++
 NEWS                              | 3 +++
 goffice/graph/gog-series-labels.c | 3 ++-
 plugins/plot_xy/gog-xy.c          | 2 ++
 4 files changed, 14 insertions(+), 1 deletion(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7daff347..f303c5ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2019-12-13  Jean Brefort  <jean brefort normalesup org>
+
+       * goffice/graph/gog-series-labels.c (gog_series_labels_update): fix warnings
+       when the vector length is nil. See #426.
+       * plugins/plot_xy/gog-xy.c (gog_xy_view_render): do not process labels 
+       if the series does not contain any valid data. Fix #426.
+
 2019-11-06  Morten Welinder <terra gnome org>
 
        * configure.ac: Post-release bump.
diff --git a/NEWS b/NEWS
index 862f33c0..de0bd9eb 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
 goffice 0.10.47:
 
+Jean:
+       * Fix crash if a XY plot series has data labels but no valid data. [#426]
+
 --------------------------------------------------------------------------
 goffice 0.10.46:
 
diff --git a/goffice/graph/gog-series-labels.c b/goffice/graph/gog-series-labels.c
index 1e761109..73a96b30 100644
--- a/goffice/graph/gog-series-labels.c
+++ b/goffice/graph/gog-series-labels.c
@@ -1242,7 +1242,8 @@ gog_series_labels_update (GogObject *obj)
                                                case 0: /* protect from an unexpected string end */
                                                        break;
                                                case 'c':
-                                                       next = GO_IS_DATA (labels->custom_labels[0].data)?
+                                                       next = (GO_IS_DATA (labels->custom_labels[0].data) &&
+                                                               go_data_get_vector_size 
(labels->custom_labels[0].data) > 0)?
                                                                        go_data_get_vector_string 
(labels->custom_labels[0].data, i):
                                                                        NULL;
                                                        if (next) {
diff --git a/plugins/plot_xy/gog-xy.c b/plugins/plot_xy/gog-xy.c
index 3d034d92..b876f326 100644
--- a/plugins/plot_xy/gog-xy.c
+++ b/plugins/plot_xy/gog-xy.c
@@ -1541,6 +1541,8 @@ gog_xy_view_render (GogView *view, GogViewAllocation const *bbox)
                        cur_x = x_vals;
                        cur_y = y_vals;
                        cur_z = z_vals;
+                       if (cur_x == NULL || cur_y == NULL)
+                               break;
                        gog_renderer_push_style (view->renderer, go_styled_object_get_style (GO_STYLED_OBJECT 
(lbls)));
                        overrides = gog_series_get_overrides (GOG_SERIES (series));
                        for (i = 1 ; i <= n ; i++) {


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