[Glamor] [PATCH 1/3] Fix _glamor_set_spans() bug (re-used 'n' variable)

Brian Paul brian.e.paul at gmail.com
Sat Oct 19 15:10:52 PDT 2013


From: Brian Paul <brianp at vmware.com>

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.
---
 src/glamor_setspans.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/glamor_setspans.c b/src/glamor_setspans.c
index a71efe9..3d447b6 100644
--- a/src/glamor_setspans.c
+++ b/src/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;
-- 
1.7.9.5



More information about the Glamor mailing list