pixman: Branch 'master' - 3 commits

Søren Sandmann Pedersen sandmann at kemper.freedesktop.org
Sat Nov 2 01:29:13 CET 2013


 configure.ac           |   16 ++++++++++++++++
 pixman/pixman-matrix.c |    2 +-
 pixman/pixman.h        |    2 +-
 test/trap-crasher.c    |   14 +++++++++++++-
 4 files changed, 31 insertions(+), 3 deletions(-)

New commits:
commit 5e14da97f16e421d084a9e735be21b1025150f0c
Author: Ritesh Khadgaray <khadgaray at gmail.com>
Date:   Wed Oct 23 17:29:07 2013 -0400

    pixman_trapezoid_valid(): Fix underflow when bottom is close to MIN_INT
    
    If t->bottom is close to MIN_INT (probably invalid value), subtracting
    top can lead to underflow which causes crashes.  Attached patch will
    fix the issue.
    
    This fixes bug 67484.

diff --git a/pixman/pixman.h b/pixman/pixman.h
index 7ff9fb5..509ba5e 100644
--- a/pixman/pixman.h
+++ b/pixman/pixman.h
@@ -1030,7 +1030,7 @@ struct pixman_triangle
 #define pixman_trapezoid_valid(t)				   \
     ((t)->left.p1.y != (t)->left.p2.y &&			   \
      (t)->right.p1.y != (t)->right.p2.y &&			   \
-     (int) ((t)->bottom - (t)->top) > 0)
+     ((t)->bottom > (t)->top))
 
 struct pixman_span_fix
 {
commit 2f876cf86718d3dd9b3b04ae9552530edafe58a1
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date:   Wed Oct 23 17:28:11 2013 -0400

    test/trap-crasher.c: Add trapezoid that demonstrates a crash
    
    This trapezoid causes a crash due to an underflow in the
    pixman_trapezoid_valid().
    
    Test case from Ritesh Khadgaray.

diff --git a/test/trap-crasher.c b/test/trap-crasher.c
index 4e4cac2..77be1c9 100644
--- a/test/trap-crasher.c
+++ b/test/trap-crasher.c
@@ -5,7 +5,7 @@ int
 main()
 {
     pixman_image_t *dst;
-    pixman_trapezoid_t traps[1] = {
+    pixman_trapezoid_t traps[] = {
 	{
 	    2147483646,
 	    2147483647,
@@ -18,6 +18,18 @@ main()
 		{ 0, 2147483647 }
 	    }
 	},
+	{
+	    32768,
+	    - 2147483647,
+	    {
+		{ 0, 0 },
+		{ 0, 2147483647 }
+	    },
+	    {
+		{ 65536, 0 },
+		{ 0, 2147483647 }
+	    }
+	},
     };
 
     dst = pixman_image_create_bits (PIXMAN_a8, 1, 1, NULL, -1);
commit 8ef7e0d18e00291da14c69d3034896235875d019
Author: Brad Smith <brad at comstyle.com>
Date:   Thu Oct 17 23:22:02 2013 -0400

    Fix pixman build with older GCC releases
    
    The following patch fixes building pixman with older GCC releases
    such as GCC 3.3 and older (OpenBSD; some older archs use GCC 3.3.6)
    by changing the method of detecting the presence of __builtin_clz
    to utilizing an autoconf check to determine its presence. Compilers
    that pretend to be GCC, implement __builtin_clz and are already
    utilizing the intrinsic include LLVM/Clang, Open64, EKOPath and
    PCC.

diff --git a/configure.ac b/configure.ac
index 8a3b622..5ccc267 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1044,6 +1044,22 @@ fi
 
 AC_MSG_RESULT($support_for_float128)
 
+dnl =====================================
+dnl __builtin_clz
+
+support_for_builtin_clz=no
+
+AC_MSG_CHECKING(for __builtin_clz)
+AC_LINK_IFELSE([AC_LANG_SOURCE([[
+unsigned int x = 11; int main (void) { return __builtin_clz(x); }
+]])], support_for_builtin_clz=yes)
+
+if test x$support_for_builtin_clz = xyes; then
+   AC_DEFINE([HAVE_BUILTIN_CLZ], [], [Whether the compiler supports __builtin_clz])
+fi
+
+AC_MSG_RESULT($support_for_builtin_clz)
+
 dnl ==================
 dnl libpng
 
diff --git a/pixman/pixman-matrix.c b/pixman/pixman-matrix.c
index 89b9682..4032c13 100644
--- a/pixman/pixman-matrix.c
+++ b/pixman/pixman-matrix.c
@@ -37,7 +37,7 @@
 static force_inline int
 count_leading_zeros (uint32_t x)
 {
-#ifdef __GNUC__
+#ifdef HAVE_BUILTIN_CLZ
     return __builtin_clz (x);
 #else
     int n = 0;


More information about the xorg-commit mailing list