polygon-intersection: Try not to invoke undefined behaviour

Optimizing compilers aggressively remove code that is executed only
after an undefined behaviour occurred.

Also, the difference of two (non char) pointers hides an integer
division that, because the divisor is known at compile time, is
transformed into a multiplication by a pseudo-reciprocal, and in this
case the difference is not always a multiple of the divisor, resulting
in an invalid comparison predicate.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=74779
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
This commit is contained in:
Massimo Valentini 2014-09-23 12:37:26 +02:00 committed by Bryce Harrington
parent a3c022bb98
commit 63f59ea896

View file

@ -76,7 +76,7 @@ struct _cairo_bo_edge {
#define PQ_LEFT_CHILD_INDEX(i) ((i) << 1)
typedef enum {
CAIRO_BO_EVENT_TYPE_STOP,
CAIRO_BO_EVENT_TYPE_STOP = -1,
CAIRO_BO_EVENT_TYPE_INTERSECTION,
CAIRO_BO_EVENT_TYPE_START
} cairo_bo_event_type_t;
@ -783,7 +783,7 @@ cairo_bo_event_compare (const cairo_bo_event_t *a,
if (cmp)
return cmp;
return a - b;
return a < b ? -1 : a == b ? 0 : 1;
}
static inline void