diff options
author | Andrea Canciani <ranma42@gmail.com> | 2010-12-09 14:38:40 +0100 |
---|---|---|
committer | Andrea Canciani <ranma42@gmail.com> | 2010-12-09 17:33:12 +0100 |
commit | 1784fd403e3dce357f018639730dd75e138904b5 (patch) | |
tree | 338a2cdd2551315e0316ef07f14d97179cf9ebef /src/cairo-arc.c | |
parent | 4314a86aa7813bcd4131827181ecf44994142a72 (diff) | |
download | cairo-1784fd403e3dce357f018639730dd75e138904b5.tar.gz |
arc: Clamp to 65536 full circles
To limit the amount of memory used for arcs describing a circle
wrapped multiple times we ignore the circles after the 65536th (but
preserve the same start and end angle mod 2pi).
Diffstat (limited to 'src/cairo-arc.c')
-rw-r--r-- | src/cairo-arc.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/cairo-arc.c b/src/cairo-arc.c index 1b2713f39..c997e5c3c 100644 --- a/src/cairo-arc.c +++ b/src/cairo-arc.c @@ -38,6 +38,8 @@ #include "cairo-arc-private.h" +#define MAX_FULL_CIRCLES 65536 + /* Spline deviation from the circle in radius would be given by: error = sqrt (x**2 + y**2) - 1 @@ -184,8 +186,13 @@ _cairo_arc_in_direction (cairo_t *cr, if (cairo_status (cr)) return; - while (angle_max - angle_min > 4 * M_PI) - angle_max -= 2 * M_PI; + assert (angle_max >= angle_min); + + if (angle_max - angle_min > 2 * M_PI * MAX_FULL_CIRCLES) { + angle_max = fmod (angle_max - angle_min, 2 * M_PI); + angle_min = fmod (angle_min, 2 * M_PI); + angle_max += angle_min + 2 * M_PI * MAX_FULL_CIRCLES; + } /* Recurse if drawing arc larger than pi */ if (angle_max - angle_min > M_PI) { |