summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMassimo Valentini <mvalentini@src.gnome.org>2014-09-23 12:37:26 +0200
committerBryce Harrington <bryce@osg.samsung.com>2015-06-04 15:01:57 -0700
commit63f59ea89625bc2f445c5ab342c0f1c3971aabea (patch)
treec43da4fed8bfa0dd4cf2512b1da1089ab5859925
parenta3c022bb98d716bd4e3f9ce50095a72e25605fe8 (diff)
downloadcairo-63f59ea89625bc2f445c5ab342c0f1c3971aabea.tar.gz
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>
-rw-r--r--src/cairo-polygon-intersect.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/cairo-polygon-intersect.c b/src/cairo-polygon-intersect.c
index 02ef3b5e2..52e67752e 100644
--- a/src/cairo-polygon-intersect.c
+++ b/src/cairo-polygon-intersect.c
@@ -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