From 3bf1eb577e2d2b4d55d38b5a0043b0efb9abb385 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 19 Oct 2013 16:10:52 -0600 Subject: [PATCH] Fix _glamor_set_spans() bug (re-used 'n' variable) n was used as a function parameter. But inside the for (i=1..n) loop, n got reassigned as REGION_NUM_RECTS() and then decremented to zero by the while loop. This caused the for loop to only iterate once instead of 'n' times. This patch renames the n parameter to numPoints. Found by code inspection. Untested. Reviewed-by: Zhigang Gong --- glamor/glamor_setspans.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/glamor/glamor_setspans.c b/glamor/glamor_setspans.c index a71efe901..3d447b606 100644 --- a/glamor/glamor_setspans.c +++ b/glamor/glamor_setspans.c @@ -30,7 +30,7 @@ static Bool _glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src, - DDXPointPtr points, int *widths, int n, int sorted, + DDXPointPtr points, int *widths, int numPoints, int sorted, Bool fallback) { PixmapPtr dest_pixmap = glamor_get_drawable_pixmap(drawable); @@ -53,9 +53,9 @@ _glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src, goto fail; glamor_get_drawable_deltas(drawable, dest_pixmap, &x_off, &y_off); - for (i = 0; i < n; i++) { + for (i = 0; i < numPoints; i++) { - n = REGION_NUM_RECTS(clip); + int n = REGION_NUM_RECTS(clip); pbox = REGION_RECTS(clip); while (n--) { int x1 = points[i].x; @@ -85,7 +85,7 @@ fail: glamor_fallback("to %p (%c)\n", drawable, glamor_get_drawable_location(drawable)); if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) { - fbSetSpans(drawable, gc, src, points, widths, n, sorted); + fbSetSpans(drawable, gc, src, points, widths, numPoints, sorted); glamor_finish_access(drawable, GLAMOR_ACCESS_RW); } ret = TRUE;