summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2013-01-05 21:11:31 +0000
committerChris Young <chris@unsatisfactorysoftware.co.uk>2013-01-05 21:11:31 +0000
commit3d74422216e1513bf651352a130ad49b9605bbf2 (patch)
tree7eff8b278a7b25648a3249ee9598a873c46f72c7
parentf30bcdde419565d50974a288c816aad30a412683 (diff)
downloadlibsvgtiny-3d74422216e1513bf651352a130ad49b9605bbf2.tar.gz
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.
-rw-r--r--src/svgtiny_gradient.c8
1 files changed, 7 insertions, 1 deletions
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",