[cairo-commit] 2 commits - src/cairo-arc.c
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sun Aug 1 11:16:07 UTC 2021
src/cairo-arc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
New commits:
commit 4dd48f0979f693dfc515eb3eff266ec6429f8b33
Merge: 6a916648d ab2c5ee21
Author: Heiko Lewin <hlewin at gmx.de>
Date: Sun Aug 1 11:16:04 2021 +0000
Merge branch 'fix_infinite_loop' into 'master'
_arc_max_angle_for_tolerance_normalized: fix infinite loop
See merge request cairo/cairo!155
commit ab2c5ee21e5f3d3ee4b3f67cfcd5811a4f99c3a0
Author: Heiko Lewin <hlewin at gmx.de>
Date: Sun Aug 1 11:16:03 2021 +0000
_arc_max_angle_for_tolerance_normalized: fix infinite loop
diff --git a/src/cairo-arc.c b/src/cairo-arc.c
index 390397bae..1c891d1a0 100644
--- a/src/cairo-arc.c
+++ b/src/cairo-arc.c
@@ -90,16 +90,18 @@ _arc_max_angle_for_tolerance_normalized (double tolerance)
{ M_PI / 11.0, 9.81410988043554039085e-09 },
};
int table_size = ARRAY_LENGTH (table);
+ const int max_segments = 1000; /* this value is chosen arbitrarily. this gives an error of about 1.74909e-20 */
for (i = 0; i < table_size; i++)
if (table[i].error < tolerance)
return table[i].angle;
++i;
+
do {
angle = M_PI / i++;
error = _arc_error_normalized (angle);
- } while (error > tolerance);
+ } while (error > tolerance && i < max_segments);
return angle;
}
More information about the cairo-commit
mailing list