summaryrefslogtreecommitdiff
path: root/src/cairo-spline.c
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2008-12-28 16:06:27 -0500
committerBehdad Esfahbod <behdad@behdad.org>2008-12-28 16:06:27 -0500
commitefb17160904eda8fdb21fa1fd10a09081cf5cb3e (patch)
treecb4bbcc228ea68675b0b9eedd7677d0a7b350447 /src/cairo-spline.c
parent0b59e29004bb19eb9bd458bbe6a48a7c367f72d0 (diff)
downloadcairo-efb17160904eda8fdb21fa1fd10a09081cf5cb3e.tar.gz
[_cairo_spline_bound] Protect against b == 0
Diffstat (limited to 'src/cairo-spline.c')
-rw-r--r--src/cairo-spline.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/cairo-spline.c b/src/cairo-spline.c
index f9b1aaf42..85e8a9038 100644
--- a/src/cairo-spline.c
+++ b/src/cairo-spline.c
@@ -209,6 +209,7 @@ _cairo_spline_decompose (cairo_spline_t *spline, double tolerance)
return _cairo_spline_add_point (spline, &spline->knots.d);
}
+/* Note: this function is only good for computing bounds in device space. */
void
_cairo_spline_bound (cairo_spline_add_point_func_t add_point_func,
void *closure,
@@ -272,7 +273,8 @@ _cairo_spline_bound (cairo_spline_add_point_func_t add_point_func,
#define FIND_EXTREMES(a,b,c) \
{ \
if (a == 0) { \
- ADD (-c / (2*b)); \
+ if (b != 0) \
+ ADD (-c / (2*b)); \
} else { \
double b2 = b * b; \
double delta = b2 - a * c; \
@@ -329,10 +331,10 @@ _cairo_spline_bound (cairo_spline_add_point_func_t add_point_func,
t_2_0 = t_1_0 * t_1_0; /* t * t */
t_0_2 = t_0_1 * t_0_1; /* (1 - t) * (1 - t) */
- t_3_0 = t_2_0 * t_1_0; /* t * t * t */
+ t_3_0 = t_2_0 * t_1_0; /* t * t * t */
t_2_1_3 = t_2_0 * t_0_1 * 3; /* t * t * (1 - t) * 3 */
t_1_2_3 = t_1_0 * t_0_2 * 3; /* t * (1 - t) * (1 - t) * 3 */
- t_0_3 = t_0_1 * t_0_2; /* (1 - t) * (1 - t) * (1 - t) */
+ t_0_3 = t_0_1 * t_0_2; /* (1 - t) * (1 - t) * (1 - t) */
/* Bezier polynomial */
x = x0 * t_0_3