From ff682089ce1128079c06827a80647fa3284ca2a2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=B8ren=20Sandmann=20Pedersen?= Date: Fri, 20 Sep 2013 02:45:32 -0400 Subject: [PATCH] utils.c: Make print_image actually cope with negative strides Commit 4312f077365bf9f59423b1694136089c6da6216b claimed to have made print_image() work with negative strides, but it didn't actually work. When the stride was negative, the image buffer would be accessed as if the stride were positive. Fix the bug by not changing the stride variable and instead using a temporary, s, that contains the absolute value of stride. --- test/utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/utils.c b/test/utils.c index 3400747..a83fc06 100644 --- a/test/utils.c +++ b/test/utils.c @@ -251,6 +251,7 @@ print_image (pixman_image_t *image) int width, height, stride; pixman_format_code_t format; uint8_t *buffer; + int s; width = pixman_image_get_width (image); height = pixman_image_get_height (image); @@ -258,13 +259,12 @@ print_image (pixman_image_t *image) format = pixman_image_get_format (image); buffer = (uint8_t *)pixman_image_get_data (image); - if (stride < 0) - stride = - stride; + s = (stride >= 0)? stride : - stride; printf ("---\n"); for (i = 0; i < height; i++) { - for (j = 0; j < stride; j++) + for (j = 0; j < s; j++) { if (j == (width * PIXMAN_FORMAT_BPP (format) + 7) / 8) printf ("| "); -- 2.7.4