From b0d532501057383297f98808f1be0c6595b8d8c9 Mon Sep 17 00:00:00 2001 From: Massimo Valentini Date: Fri, 8 Aug 2014 12:35:12 +0200 Subject: [PATCH] assert non negative remainder --- src/cairo-polygon-intersect.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cairo-polygon-intersect.c b/src/cairo-polygon-intersect.c index 08a52d2..e3cd5eb 100644 --- a/src/cairo-polygon-intersect.c +++ b/src/cairo-polygon-intersect.c @@ -624,6 +624,11 @@ intersect_lines (cairo_bo_edge_t *a, } else intersection->x.exactness = INEXACT; } + + /* num = q * den + r -> r = num - q * den -> r >= 0 num >= q * den */ + assert (_cairo_int128_ge (det64x32_128 (a_det, dx1, b_det, dx2), + _cairo_int64x64_128_mul (qr.quo, den_det))); + #endif intersection->x.ordinate = _cairo_int64_to_int32 (qr.quo); -- 1.9.3