mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-14 14:28:17 +02:00
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).
This commit is contained in:
parent
4314a86aa7
commit
1784fd403e
1 changed files with 9 additions and 2 deletions
|
|
@ -38,6 +38,8 @@
|
||||||
|
|
||||||
#include "cairo-arc-private.h"
|
#include "cairo-arc-private.h"
|
||||||
|
|
||||||
|
#define MAX_FULL_CIRCLES 65536
|
||||||
|
|
||||||
/* Spline deviation from the circle in radius would be given by:
|
/* Spline deviation from the circle in radius would be given by:
|
||||||
|
|
||||||
error = sqrt (x**2 + y**2) - 1
|
error = sqrt (x**2 + y**2) - 1
|
||||||
|
|
@ -184,8 +186,13 @@ _cairo_arc_in_direction (cairo_t *cr,
|
||||||
if (cairo_status (cr))
|
if (cairo_status (cr))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while (angle_max - angle_min > 4 * M_PI)
|
assert (angle_max >= angle_min);
|
||||||
angle_max -= 2 * M_PI;
|
|
||||||
|
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 */
|
/* Recurse if drawing arc larger than pi */
|
||||||
if (angle_max - angle_min > M_PI) {
|
if (angle_max - angle_min > M_PI) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue