diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2013-10-07 10:30:20 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2013-10-07 10:30:20 +0100 |
commit | 1c651848cc3f3baec8fa0bcfc68faebd3e58c069 (patch) | |
tree | f6dfd42a8f34d9855c5ef0ede4314fa3a80216ee /src/sna/sna_trapezoids_imprecise.c | |
parent | d462475b7ecca6eb001b521185d2f7286031a8d8 (diff) |
sna/trapezoids: Restore overflow check
The range can indeed overflow, so promote the assertion back into a
check.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/sna/sna_trapezoids_imprecise.c')
-rw-r--r-- | src/sna/sna_trapezoids_imprecise.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/sna/sna_trapezoids_imprecise.c b/src/sna/sna_trapezoids_imprecise.c index 2cfab805..6ca3fedb 100644 --- a/src/sna/sna_trapezoids_imprecise.c +++ b/src/sna/sna_trapezoids_imprecise.c @@ -467,7 +467,8 @@ polygon_init(struct polygon *polygon, unsigned num_buckets = EDGE_Y_BUCKET_INDEX(ymax+EDGE_Y_BUCKET_HEIGHT-1, ymin); - assert(ymax-ymin < 0x7FFFFFFFU - EDGE_Y_BUCKET_HEIGHT); + if (unlikely(ymax - ymin > 0x7FFFFFFFU - EDGE_Y_BUCKET_HEIGHT)) + return false; polygon->edges = polygon->edges_embedded; polygon->y_buckets = polygon->y_buckets_embedded; @@ -936,8 +937,8 @@ tor_init(struct tor *converter, const BoxRec *box, int num_edges) active_list_reset(converter->active); if (!polygon_init(converter->polygon, num_edges, - box->y1 * FAST_SAMPLES_Y, - box->y2 * FAST_SAMPLES_Y)) { + (int)box->y1 * FAST_SAMPLES_Y, + (int)box->y2 * FAST_SAMPLES_Y)) { cell_list_fini(converter->coverages); return false; } |