Don't read potentially uninitialized data in pixman_CombineMaskU()
authorSøren Sandmann Pedersen <sandmann@redhat.com>
Sat, 16 May 2009 12:33:35 +0000 (08:33 -0400)
committerSøren Sandmann Pedersen <sandmann@redhat.com>
Sat, 16 May 2009 15:50:44 +0000 (11:50 -0400)
This is mainly to quiet valgrind. The data in question would only be
uninitialized when the corresponding mask pixel was zero, so the end
result is zero in any case.

pixman/combine.inc

index ff18732..ef19d01 100644 (file)
 static force_inline comp4_t
 combineMask (const comp4_t *src, const comp4_t *mask, int i)
 {
-    comp4_t s = *(src + i);
+    comp4_t s, m;
 
     if (mask)
     {
-       comp4_t m = *(mask + i) >> A_SHIFT;
-       
-       FbByteMul (s, m);
+       m = *(mask + i) >> A_SHIFT;
+
+       if (!m)
+           return 0;
     }
-    
+
+    s = *(src + i);
+
+    if (mask)
+       FbByteMul (s, m);
+
     return s;
 }