From a0fae4657fab4f1708449d5ee5e1b92e5e90c0aa Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Mon, 18 Aug 2014 16:13:41 -0500 Subject: [PATCH] cliptest: Avoid use of uninitialized memory when regions don't intersect Prevent attempting to draw the intersection polygon when it contains no vertices. Signed-off-by: Derek Foreman Reviewed-by: Pekka Paalanen --- clients/cliptest.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/clients/cliptest.c b/clients/cliptest.c index 612b3d13..907c5d43 100644 --- a/clients/cliptest.c +++ b/clients/cliptest.c @@ -570,12 +570,14 @@ draw_geometry(cairo_t *cr, struct weston_surface *surface, cairo_set_source_rgba(cr, 0.0, 0.0, 1.0, 0.4); cairo_fill(cr); - draw_polygon_closed(cr, ex, ey, n); - cairo_set_source_rgb(cr, 0.0, 1.0, 0.0); - cairo_stroke(cr); + if (n) { + draw_polygon_closed(cr, ex, ey, n); + cairo_set_source_rgb(cr, 0.0, 1.0, 0.0); + cairo_stroke(cr); - cairo_set_source_rgba(cr, 0.0, 1.0, 0.0, 0.5); - draw_polygon_labels(cr, ex, ey, n); + cairo_set_source_rgba(cr, 0.0, 1.0, 0.0, 0.5); + draw_polygon_labels(cr, ex, ey, n); + } } static void