[goffice] Fix access to NULL data in pies and rings. [#601618]



commit 43745392741304c405c72654e77e86aaf57a5eb5
Author: Jean Brefort <jean brefort normalesup org>
Date:   Thu Nov 12 11:24:10 2009 +0100

    Fix access to NULL data in pies and rings. [#601618]

 ChangeLog                  |    5 +++++
 plugins/plot_pie/gog-pie.c |    7 +++----
 2 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7737b03..9a07a8e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-11-12  Jean Brefort  <jean brefort normalesup org>
+
+	* plugins/plot_pie/gog-pie.c (gog_pie_view_get_data_at_point): do not
+	access NULL data. [#601618]
+
 2009-11-09  Jean Brefort  <jean brefort normalesup org>
 
 	* goffice/canvas/goc-graph.c (goc_graph_do_tooltip): use
diff --git a/plugins/plot_pie/gog-pie.c b/plugins/plot_pie/gog-pie.c
index fcfcfe0..4ef62f2 100644
--- a/plugins/plot_pie/gog-pie.c
+++ b/plugins/plot_pie/gog-pie.c
@@ -640,7 +640,6 @@ gog_pie_view_get_data_at_point (GogPlotView *view, double x, double y, GogSeries
 	double center_size = 0.0;
 	unsigned num_series = 0;
 	double default_sep;
-	int ret = -1;
 	GSList *ptr;
 
 	/* compute number of valid series */
@@ -687,6 +686,8 @@ gog_pie_view_get_data_at_point (GogPlotView *view, double x, double y, GogSeries
 		theta += 1.;
 
 	vals = go_data_get_values ((*series)->values[1].data);
+	if (!vals)
+		return -1;
 	scale = 1 / GOG_PIE_SERIES (*series)->total;
 	for (index = 0 ; index < (*series)->num_elements; index++) {
 		r = vals[index] * scale;
@@ -698,9 +699,7 @@ gog_pie_view_get_data_at_point (GogPlotView *view, double x, double y, GogSeries
 				break;
 		}
 	}
-	/* using r to store the value */
 	return (int) index;
-	return ret;
 }
 
 #define MAX_ARC_SEGMENTS 64
@@ -740,7 +739,7 @@ gog_pie_view_render (GogView *view, GogViewAllocation const *bbox)
 
 	if (num_series <= 0)
 		return;
-
+	
 	separation_max = .0;
 	outline_width_max = .0;
 	if ((style = go_styled_object_get_style (GO_STYLED_OBJECT (series))))



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