[Pixman] [PATCH] Fix use of uninitialized fields reported by valgrind

Søren Sandmann sandmann at cs.au.dk
Tue Oct 25 09:01:12 PDT 2011


From: Søren Sandmann Pedersen <ssp at redhat.com>

In pixman-noop.c and pixman-sse2.c, we are accessing
image->bits.width/height without first making sure the image is a bits
image. The warning is harmless because we never act on this
information without checking that the image is a8r8g8b8, but valgrind
does warn about it.

In pixman-noop.c, just reorder the clauses in the if statement; in
pixman-sse2.c require images to have the FAST_PATH_BITS_IMAGE flag
set.
---
 pixman/pixman-noop.c |    6 +++---
 pixman/pixman-sse2.c |    2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/pixman/pixman-noop.c b/pixman/pixman-noop.c
index 906a491..f4012d8 100644
--- a/pixman/pixman-noop.c
+++ b/pixman/pixman-noop.c
@@ -76,12 +76,12 @@ noop_src_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter)
     {
 	iter->get_scanline = _pixman_iter_get_scanline_noop;
     }
-    else if ((iter->flags & ITER_NARROW)				&&
+    else if (image->common.extended_format_code == PIXMAN_a8r8g8b8	&&
+	     (iter->flags & ITER_NARROW)				&&
 	     (image->common.flags & FLAGS) == FLAGS			&&
 	     iter->x >= 0 && iter->y >= 0				&&
 	     iter->x + iter->width <= image->bits.width			&&
-	     iter->y + iter->height <= image->bits.height		&&
-	     image->common.extended_format_code == PIXMAN_a8r8g8b8)
+	     iter->y + iter->height <= image->bits.height)
     {
 	iter->buffer =
 	    image->bits.bits + iter->y * image->bits.rowstride + iter->x;
diff --git a/pixman/pixman-sse2.c b/pixman/pixman-sse2.c
index c419511..8adf541 100644
--- a/pixman/pixman-sse2.c
+++ b/pixman/pixman-sse2.c
@@ -5982,7 +5982,7 @@ sse2_src_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter)
     int height = iter->height;
 
 #define FLAGS								\
-    (FAST_PATH_STANDARD_FLAGS | FAST_PATH_ID_TRANSFORM)
+    (FAST_PATH_STANDARD_FLAGS | FAST_PATH_ID_TRANSFORM | FAST_PATH_BITS_IMAGE)
 
     if ((iter->flags & ITER_NARROW)				&&
 	(image->common.flags & FLAGS) == FLAGS			&&
-- 
1.7.4



More information about the Pixman mailing list