gnumeric r16562 - in trunk: . src
- From: mortenw svn gnome org
- To: svn-commits-list gnome org
- Subject: gnumeric r16562 - in trunk: . src
- Date: Fri, 16 May 2008 16:27:55 +0100 (BST)
Author: mortenw
Date: Fri May 16 15:27:55 2008
New Revision: 16562
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16562&view=rev
Log:
2008-05-15 Morten Welinder <terra gnome org>
* src/mathfunc.c (random_gamma): Handle overflow and bogus
arguments. Fixes #533288.
Modified:
trunk/ChangeLog
trunk/NEWS
trunk/src/mathfunc.c
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Fri May 16 15:27:55 2008
@@ -3,6 +3,7 @@
Morten:
* Fix Excel export problem for strings that need quoting. [#530704]
* Internal cleanup for analysis tools. [#532210]
+ * Fix hang. [#533288]
--------------------------------------------------------------------------
Gnumeric 1.9.0
Modified: trunk/src/mathfunc.c
==============================================================================
--- trunk/src/mathfunc.c (original)
+++ trunk/src/mathfunc.c Fri May 16 15:27:55 2008
@@ -6804,16 +6804,17 @@
}
static gnm_float
-ran_gamma_int (unsigned int a)
+ran_gamma_int (gnm_float a)
{
if (a < 12) {
gnm_float prod;
do {
- unsigned int i;
+ unsigned int i, ua;
prod = 1;
+ ua = (unsigned int)a;
- for (i = 0; i < a; i++)
+ for (i = 0; i < ua; i++)
prod *= random_01 ();
/*
@@ -6835,9 +6836,12 @@
gnm_float
random_gamma (gnm_float a, gnm_float b)
{
- /* assume a > 0 */
- /* FIXME: why not simply a gnm_float? */
- unsigned int na = gnm_floor (a);
+ gnm_float na;
+
+ if (gnm_isnan (a) || gnm_isnan (b) || a <= 0 || b <= 0)
+ return gnm_nan;
+
+ na = gnm_floor (a);
if (a == na)
return b * ran_gamma_int (na);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]