gnumeric r16603 - in trunk: . plugins/fn-stat



Author: mortenw
Date: Sat May 24 17:44:40 2008
New Revision: 16603
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16603&view=rev

Log:
2008-05-24  Morten Welinder  <terra gnome org>

	* functions.c (gnumeric_trend): Fix error handling and don't
	evaluate things twice.  Fixes #534587.



Modified:
   trunk/NEWS
   trunk/plugins/fn-stat/ChangeLog
   trunk/plugins/fn-stat/functions.c

Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS	(original)
+++ trunk/NEWS	Sat May 24 17:44:40 2008
@@ -22,6 +22,7 @@
 	* Fix RANDEXPPOW hang.  [#533965]
 	* Fix array evaluation problem.  [#533953]
 	* Fix COUNTBLANK crash.  [#534204]
+	* Fix TREND crash.  [#534587]
 
 SeÃn de BÃrca:
 	* Move to tango based icons. [#450444]

Modified: trunk/plugins/fn-stat/functions.c
==============================================================================
--- trunk/plugins/fn-stat/functions.c	(original)
+++ trunk/plugins/fn-stat/functions.c	Sat May 24 17:44:40 2008
@@ -4592,11 +4592,16 @@
 					   COLLECT_IGNORE_STRINGS |
 					   COLLECT_IGNORE_BOOLS,
 					   &nx, &result);
+		if (result)
+			goto out;
 
 		nxs = collect_floats_value (argv[2], ei->pos,
 					    COLLECT_IGNORE_STRINGS |
 					    COLLECT_IGNORE_BOOLS,
 					    &nnx, &result);
+		if (result)
+			goto out;
+
 		if (argv[3] != NULL) {
 			affine = value_get_as_bool (argv[3], &err);
 			if (err) {
@@ -4605,28 +4610,28 @@
 			}
 		}
 	} else {
-		/* @new_x's is assumed to be the same as @known_x's */
 		if (argv[1] != NULL) {
 			xs = collect_floats_value (argv[1], ei->pos,
 						   COLLECT_IGNORE_STRINGS |
 						   COLLECT_IGNORE_BOOLS,
 						   &nx, &result);
-			nxs = collect_floats_value (argv[1], ei->pos,
-						    COLLECT_IGNORE_STRINGS |
-						    COLLECT_IGNORE_BOOLS,
-						    &nnx, &result);
+			if (result)
+				goto out;
 		} else {
 			xs = g_new (gnm_float, ny);
 			for (nx = 0; nx < ny; nx++)
 				xs[nx] = nx + 1;
-			nxs = g_new (gnm_float, ny);
-			for (nnx = 0; nnx < ny; nnx++)
-				xs[nnx] = nnx + 1;
 		}
+
+		/* @new_x's is assumed to be the same as @known_x's */
+		nnx = nx;
+		nxs = g_memdup (xs, nnx * sizeof (*xs));
 	}
 
-	if (result || ny < 1)
+	if (ny < 1 || nnx < 1) {
+		result = value_new_error_NUM (ei->pos);
 		goto out;
+	}
 
 	if (nx != ny) {
 		result = value_new_error_NUM (ei->pos);



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