mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-09 03:48:03 +02:00
Eliminate a potential infinite loop in spline stroking
Sometimes > rather than >= can make a bug difference. The infinite loop was noticed here: Infinite loop when scaling very small values using 24.8 http://bugs.freedesktop.org/show_bug.cgi?id=14280 Note that that particular test case only exposes the infinite loop when using 24.8 instead of 16.16 fixed-point values by setting CAIRO_FIXED_FRAC_BITS to 8.
This commit is contained in:
parent
770b058c9e
commit
d6d81c92b5
1 changed files with 12 additions and 1 deletions
|
|
@ -417,7 +417,18 @@ _cairo_pen_stroke_spline_half (cairo_pen_t *pen,
|
|||
slope = final_slope;
|
||||
else
|
||||
_cairo_slope_init (&slope, &point[i], &point[i+step]);
|
||||
if (_cairo_slope_compare (&slope, &pen->vertices[active].slope_ccw) >= 0) {
|
||||
|
||||
/* The strict inequalities here ensure that if a spline slope
|
||||
* compares identically with either of the slopes of the
|
||||
* active vertex, then it remains the active vertex. This is
|
||||
* very important since otherwise we can trigger an infinite
|
||||
* loop in the case of a degenerate pen, (a line), where
|
||||
* neither vertex considers itself active for the slope---one
|
||||
* will consider it as equal and reject, and the other will
|
||||
* consider it unequal and reject. This is due to the inherent
|
||||
* ambiguity when comparing slopes that differ by exactly
|
||||
* pi. */
|
||||
if (_cairo_slope_compare (&slope, &pen->vertices[active].slope_ccw) > 0) {
|
||||
if (++active == pen->num_vertices)
|
||||
active = 0;
|
||||
} else if (_cairo_slope_compare (&slope, &pen->vertices[active].slope_cw) < 0) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue