From 3d74422216e1513bf651352a130ad49b9605bbf2 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sat, 5 Jan 2013 21:11:31 +0000 Subject: Explicitly check if r0 or r1 are NaN, as if they are, on x86 the function evaluates as 0 (which is already handled), but on PPC the function evaluates to a negative value, causing the following for loop to become infinite. --- src/svgtiny_gradient.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/svgtiny_gradient.c') diff --git a/src/svgtiny_gradient.c b/src/svgtiny_gradient.c index 002c322..e330024 100644 --- a/src/svgtiny_gradient.c +++ b/src/svgtiny_gradient.c @@ -462,7 +462,13 @@ svgtiny_code svgtiny_add_path_linear_gradient(float *p, unsigned int n, gradient_norm_squared; /* determine steps from change in r */ - steps = ceilf(fabsf(r1 - r0) / 0.05); + + if(isnan(r0) || isnan(r1)) { + steps = 1; + } else { + steps = ceilf(fabsf(r1 - r0) / 0.05); + } + if (steps == 0) steps = 1; fprintf(stderr, "r0 %g, r1 %g, steps %i\n", -- cgit v1.2.3