[goffice] Don't access a GODataVector with an index larger than its length.



commit a84e4a0cb0e319f9c67b7a8f967b7a8a354b6584
Author: Jean Brefort <jean brefort normalesup org>
Date:   Tue Jul 13 23:10:10 2010 +0200

    Don't access a GODataVector with an index larger than its length.

 ChangeLog                  |    5 +++++
 goffice/canvas/goc-graph.c |    6 +++---
 2 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 83c3732..fcb04b2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2010-07-13  Jean Brefort  <jean brefort normalesup org>
 
+	* goffice/canvas/goc-graph.c (goc_graph_do_tooltip): don't access a
+	GODataVector with an index larger than its length.
+
+2010-07-13  Jean Brefort  <jean brefort normalesup org>
+
 	* plugins/plot_surface/gog-contour.c
 	(gog_contour_plot_foreach_elem): Fixed legend when the pseudo-3D axis
 	has a manually set minimum. [#623887]
diff --git a/goffice/canvas/goc-graph.c b/goffice/canvas/goc-graph.c
index 5518714..2cb12c0 100644
--- a/goffice/canvas/goc-graph.c
+++ b/goffice/canvas/goc-graph.c
@@ -319,9 +319,9 @@ goc_graph_do_tooltip (GocGraph *graph)
 				y >= alloc.y && y < alloc.y + alloc.h) {
 		gog_chart_map_view_to_2D (map, x, y, &x, &y);
 		if (gog_axis_is_discrete (x_axis)) {
-			GOData *labels = gog_axis_get_labels (x_axis, NULL);
-			if (labels)
-				s1 = go_data_vector_get_str (GO_DATA_VECTOR (labels), x - 1);
+			GODataVector *labels = GO_DATA_VECTOR (gog_axis_get_labels (x_axis, NULL));
+			if (labels && x <= go_data_vector_get_len (labels))
+				s1 = go_data_vector_get_str (labels, x - 1);
 			if (!s1 || *s1 == 0) {
 				g_free (s1);
 				s1 = format_coordinate (x_axis, NULL, x);



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