[gnumeric] INTERPOLATION: fix crash.



commit a975195448ec1e26470ecf3d411e56a530f55370
Author: Morten Welinder <terra gnome org>
Date:   Thu Mar 15 15:01:08 2012 -0400

    INTERPOLATION: fix crash.

 NEWS                       |    1 +
 plugins/fn-tsa/ChangeLog   |    5 +++++
 plugins/fn-tsa/functions.c |    9 +++++++++
 3 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/NEWS b/NEWS
index f868b94..65bda2a 100644
--- a/NEWS
+++ b/NEWS
@@ -36,6 +36,7 @@ Morten:
 	* Lower memory usage for ods load.  [#671863]
 	* Improve test suite.
 	* Lower per-cell memory usage.
+	* Fix INTERPOLATION crash.  [#672154]
 
 --------------------------------------------------------------------------
 Gnumeric 1.11.2
diff --git a/plugins/fn-tsa/ChangeLog b/plugins/fn-tsa/ChangeLog
index 5a250cf..fd925c0 100644
--- a/plugins/fn-tsa/ChangeLog
+++ b/plugins/fn-tsa/ChangeLog
@@ -1,3 +1,8 @@
+2012-03-15  Morten Welinder  <terra gnome org>
+
+	* functions.c (staircase_interpolation, staircase_averaging):
+	Handle the no-points case.  Fixes #672154.
+
 2012-03-02  Morten Welinder <terra gnome org>
 
 	* Release 1.11.2
diff --git a/plugins/fn-tsa/functions.c b/plugins/fn-tsa/functions.c
index 27a8271..6735898 100644
--- a/plugins/fn-tsa/functions.c
+++ b/plugins/fn-tsa/functions.c
@@ -250,6 +250,10 @@ staircase_interpolation (const gnm_float *absc, const gnm_float *ord, int nb_kno
 {
 	int i, j, jmax = nb_knots - 1;
 	gnm_float *res;
+
+	if (nb_knots <= 0)
+		return NULL;
+
 	res = g_new (gnm_float, nb_targets);
 	if (gnm_range_increasing (targets, nb_targets)) {
 		j = 1;
@@ -290,6 +294,11 @@ staircase_averaging (const gnm_float *absc, const gnm_float *ord, int nb_knots,
 {
 	int i, j, jmax = nb_knots - 1;
 	gnm_float *res;
+
+
+	if (nb_knots <= 0)
+		return NULL;
+
 	if (!gnm_range_increasing (targets, nb_targets + 1))
 		return NULL;
 	res = g_new (gnm_float, nb_targets);



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