[gnumeric] Fix a wrong use of gnm_expr_is_rangeref. [related to #667237]



commit 41478d55ecc050a465127130f7e3957b6526fda1
Author: Jean Brefort <jean brefort normalesup org>
Date:   Sun Jan 8 10:31:52 2012 +0100

    Fix a wrong use of gnm_expr_is_rangeref. [related to #667237]

 ChangeLog   |    5 +++++
 src/graph.c |   27 ++++++++++++++-------------
 2 files changed, 19 insertions(+), 13 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e3ee906..b670ec1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-01-08  Jean Brefort  <jean brefort normalesup org>
+
+	* src/graph.c (gnm_go_data_vector_load_len): fix a wrong use of
+	gnm_expr_is_rangeref. [related to #667237]
+
 2012-01-06  Morten Welinder  <terra gnome org>
 
 	* src/rendered-value.h (GnmRenderedRotatedValue): Storing six
diff --git a/src/graph.c b/src/graph.c
index 83b3f31..acd13ba 100644
--- a/src/graph.c
+++ b/src/graph.c
@@ -509,25 +509,26 @@ gnm_go_data_vector_load_len (GODataVector *dat)
 
 	eval_pos_init_dep (&ep, &vec->dep);
 	if (vec->val == NULL && vec->dep.texpr != NULL) {
-		GSList *l;
-		if (gnm_expr_is_rangeref (vec->dep.texpr->expr) && ((l = gnm_expr_top_get_ranges (vec->dep.texpr)))) {
+		GSList *l = NULL;
+		if (gnm_expr_is_rangeref (vec->dep.texpr->expr) && ((l = gnm_expr_top_get_ranges (vec->dep.texpr))) && l->next != NULL) {
 			unsigned len = g_slist_length (l);
-			if (l->next == NULL) /* only one range */
-				vec->val = l->data;
-			else {
-				GSList *cur = l;
-				unsigned i;
-				vec->val = value_new_array_empty (len, 1);
-				for (i = 0; i < len; i++) {
-					vec->val->v_array.vals[i][0] = cur->data;
-					cur = cur->next;
-				}
+			GSList *cur = l;
+			unsigned i;
+			vec->val = value_new_array_empty (len, 1);
+			for (i = 0; i < len; i++) {
+				vec->val->v_array.vals[i][0] = cur->data;
+				cur = cur->next;
 			}
-			g_slist_free (l);
 		} else {
+			if (l) {
+				GSList *cur;
+				for (cur = l; cur != NULL; cur = cur->next)
+					value_release (cur->data);
+			}
 			vec->val = gnm_expr_top_eval (vec->dep.texpr, &ep,
 				GNM_EXPR_EVAL_PERMIT_NON_SCALAR | GNM_EXPR_EVAL_PERMIT_EMPTY);
 		}
+		g_slist_free (l);
 	}
 
 	if (vec->val != NULL) {



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