[cairo] Propagate errors in pixman

Chris Wilson chris at chris-wilson.co.uk
Tue Mar 27 16:32:31 PDT 2007


pixman is inconsistent in its return codes for error status often using
1 to flag an error, but sometimes using 0.  All I can say is that I've
reviewed it a couple of times and it passes make check[-valgrind]...
--
Chris Wilson
-------------- next part --------------
>From 6dbfc0e1949ac3736170b313933cc0ce30d1df86 Mon Sep 17 00:00:00 2001
From: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed, 28 Mar 2007 00:26:24 +0100
Subject: [PATCH] Propagate errors throughout pixman_private functions.

A few paths were silently returning when an error occurred. This patch
propagates the error (usually a result of a malloc failure) back to the
caller.
---
 pixman/src/fbcompose.c |   19 ++-
 pixman/src/fbmmx.c     |   84 ++++++----
 pixman/src/fbmmx.h     |  428 ++++++++++++++++++++++++------------------------
 pixman/src/fbpict.c    |  125 ++++++++++-----
 pixman/src/fbpict.h    |    2 +-
 pixman/src/icimage.c   |   47 ++++--
 pixman/src/icimage.h   |    4 +-
 pixman/src/icrect.c    |   92 ++++++++---
 pixman/src/ictrap.c    |   37 +++--
 pixman/src/ictri.c     |   92 +++++++----
 pixman/src/pixman.h    |   14 +-
 11 files changed, 559 insertions(+), 385 deletions(-)

diff --git a/pixman/src/fbcompose.c b/pixman/src/fbcompose.c
index 233b90c..4086100 100644
--- a/pixman/src/fbcompose.c
+++ b/pixman/src/fbcompose.c
@@ -4182,7 +4182,7 @@ fbCompositeRect (const FbComposeData *data, CARD32 *scanline_buffer)
     }
 }
 
-void
+int
 pixman_compositeGeneral (pixman_operator_t	op,
 		    PicturePtr	pSrc,
 		    PicturePtr	pMask,
@@ -4218,7 +4218,15 @@ pixman_compositeGeneral (pixman_operator_t	op,
         op = PIXMAN_OPERATOR_SRC;
 
     region = pixman_region_create();
-    pixman_region_union_rect (region, region, xDst, yDst, width, height);
+    if (!region)
+	return 1;
+    if (pixman_region_union_rect (region, region,
+		                  xDst, yDst,
+				  width, height) !=
+	    PIXMAN_REGION_STATUS_SUCCESS) {
+	pixman_region_destroy (region);
+	return 1;
+    }
 
     if (!FbComputeCompositeRegion (region,
 				   pSrc,
@@ -4231,8 +4239,10 @@ pixman_compositeGeneral (pixman_operator_t	op,
 				   xDst,
 				   yDst,
 				   width,
-				   height))
-	    return;
+				   height)) {
+	pixman_region_destroy (region);
+	return 1;
+    }
 
     compose_data.op = op;
     compose_data.src = pSrc;
@@ -4300,6 +4310,7 @@ pixman_compositeGeneral (pixman_operator_t	op,
 
     if (scanline_buffer != _scanline_buffer)
         free(scanline_buffer);
+    return 0;
 }
 
 #endif
diff --git a/pixman/src/fbmmx.c b/pixman/src/fbmmx.c
index 387d4b4..4749361 100644
--- a/pixman/src/fbmmx.c
+++ b/pixman/src/fbmmx.c
@@ -915,7 +915,7 @@ void fbComposeSetupMMX(void)
 
 /* ------------------ MMX code paths called from fbpict.c ----------------------- */
 
-void
+int
 fbCompositeSolid_nx8888mmx (pixman_operator_t	op,
 			    PicturePtr pSrc,
 			    PicturePtr pMask,
@@ -940,7 +940,7 @@ fbCompositeSolid_nx8888mmx (pixman_operator_t	op,
     fbComposeGetSolid(pSrc, pDst, src);
 
     if (src >> 24 == 0)
-	return;
+	return 0;
 
     fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
 
@@ -991,9 +991,10 @@ fbCompositeSolid_nx8888mmx (pixman_operator_t	op,
     }
 
     _mm_empty();
+    return 0;
 }
 
-void
+int
 fbCompositeSolid_nx0565mmx (pixman_operator_t	op,
 			    PicturePtr pSrc,
 			    PicturePtr pMask,
@@ -1018,7 +1019,7 @@ fbCompositeSolid_nx0565mmx (pixman_operator_t	op,
     fbComposeGetSolid(pSrc, pDst, src);
 
     if (src >> 24 == 0)
-	return;
+	return 0;
 
     fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
 
@@ -1074,9 +1075,10 @@ fbCompositeSolid_nx0565mmx (pixman_operator_t	op,
     }
 
     _mm_empty();
+    return 0;
 }
 
-void
+int
 fbCompositeSolidMask_nx8888x8888Cmmx (pixman_operator_t	op,
 				      PicturePtr pSrc,
 				      PicturePtr pMask,
@@ -1102,7 +1104,7 @@ fbCompositeSolidMask_nx8888x8888Cmmx (pixman_operator_t	op,
 
     srca = src >> 24;
     if (srca == 0)
-	return;
+	return 0;
 
     fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
     fbComposeGetStart (pMask, xMask, yMask, CARD32, maskStride, maskLine, 1);
@@ -1177,9 +1179,10 @@ fbCompositeSolidMask_nx8888x8888Cmmx (pixman_operator_t	op,
     }
 
     _mm_empty();
+    return 0;
 }
 
-void
+int
 fbCompositeSrc_8888x8x8888mmx (pixman_operator_t	op,
 			       PicturePtr pSrc,
 			       PicturePtr pMask,
@@ -1262,9 +1265,10 @@ fbCompositeSrc_8888x8x8888mmx (pixman_operator_t	op,
     }
 
     _mm_empty();
+    return 0;
 }
 
-void
+int
 fbCompositeSrc_x888x8x8888mmx (pixman_operator_t	op,
 			       PicturePtr pSrc,
 			       PicturePtr pMask,
@@ -1397,9 +1401,10 @@ fbCompositeSrc_x888x8x8888mmx (pixman_operator_t	op,
     }
 
     _mm_empty();
+    return 0;
 }
 
-void
+int
 fbCompositeSrc_8888x8888mmx (pixman_operator_t      op,
 			     PicturePtr pSrc,
 			     PicturePtr pMask,
@@ -1446,9 +1451,10 @@ fbCompositeSrc_8888x8888mmx (pixman_operator_t      op,
 	}
     }
     _mm_empty();
+    return 0;
 }
 
-void
+int
 fbCompositeSrc_8888x0565mmx (pixman_operator_t      op,
 			     PicturePtr pSrc,
 			     PicturePtr pMask,
@@ -1540,9 +1546,10 @@ fbCompositeSrc_8888x0565mmx (pixman_operator_t      op,
     }
 
     _mm_empty();
+    return 0;
 }
 
-void
+int
 fbCompositeSolidMask_nx8x8888mmx (pixman_operator_t      op,
 				  PicturePtr pSrc,
 				  PicturePtr pMask,
@@ -1570,7 +1577,7 @@ fbCompositeSolidMask_nx8x8888mmx (pixman_operator_t      op,
 
     srca = src >> 24;
     if (srca == 0)
-	return;
+	return 0;
 
     srcsrc = (ullong)src << 32 | src;
 
@@ -1655,9 +1662,10 @@ fbCompositeSolidMask_nx8x8888mmx (pixman_operator_t      op,
     }
 
     _mm_empty();
+    return 0;
 }
 
-void
+int
 fbCompositeSolidMaskSrc_nx8x8888mmx (pixman_operator_t      op,
 				     PicturePtr pSrc,
 				     PicturePtr pMask,
@@ -1687,7 +1695,7 @@ fbCompositeSolidMaskSrc_nx8x8888mmx (pixman_operator_t      op,
     if (srca == 0)
     {
 	if (fbSolidFillmmx (pDst->pDrawable, xDst, yDst, width, height, 0))
-	    return;
+	    return 0;
     }
 
     srcsrc = (ullong)src << 32 | src;
@@ -1785,9 +1793,10 @@ fbCompositeSolidMaskSrc_nx8x8888mmx (pixman_operator_t      op,
     }
 
     _mm_empty();
+    return 0;
 }
 
-void
+int
 fbCompositeSolidMask_nx8x0565mmx (pixman_operator_t      op,
 				  PicturePtr pSrc,
 				  PicturePtr pMask,
@@ -1816,7 +1825,7 @@ fbCompositeSolidMask_nx8x0565mmx (pixman_operator_t      op,
 
     srca = src >> 24;
     if (srca == 0)
-	return;
+	return 0;
 
     fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
     fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
@@ -1914,9 +1923,10 @@ fbCompositeSolidMask_nx8x0565mmx (pixman_operator_t      op,
     }
 
     _mm_empty();
+    return 0;
 }
 
-void
+int
 fbCompositeSrc_8888RevNPx0565mmx (pixman_operator_t      op,
 				  PicturePtr pSrc,
 				  PicturePtr pMask,
@@ -2028,11 +2038,12 @@ fbCompositeSrc_8888RevNPx0565mmx (pixman_operator_t      op,
     }
 
     _mm_empty();
+    return 0;
 }
 
 /* "8888RevNP" is GdkPixbuf's format: ABGR, non premultiplied */
 
-void
+int
 fbCompositeSrc_8888RevNPx8888mmx (pixman_operator_t      op,
 				  PicturePtr pSrc,
 				  PicturePtr pMask,
@@ -2126,9 +2137,10 @@ fbCompositeSrc_8888RevNPx8888mmx (pixman_operator_t      op,
     }
 
     _mm_empty();
+    return 0;
 }
 
-void
+int
 fbCompositeSolidMask_nx8888x0565Cmmx (pixman_operator_t      op,
 				      PicturePtr pSrc,
 				      PicturePtr pMask,
@@ -2154,7 +2166,7 @@ fbCompositeSolidMask_nx8888x0565Cmmx (pixman_operator_t      op,
 
     srca = src >> 24;
     if (srca == 0)
-	return;
+	return 0;
 
     fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
     fbComposeGetStart (pMask, xMask, yMask, CARD32, maskStride, maskLine, 1);
@@ -2231,9 +2243,10 @@ fbCompositeSolidMask_nx8888x0565Cmmx (pixman_operator_t      op,
     }
 
     _mm_empty ();
+    return 0;
 }
 
-void
+int
 fbCompositeIn_nx8x8mmx (pixman_operator_t	op,
 			PicturePtr pSrc,
 			PicturePtr pMask,
@@ -2262,7 +2275,7 @@ fbCompositeIn_nx8x8mmx (pixman_operator_t	op,
 
     sa = src >> 24;
     if (sa == 0)
-	return;
+	return 0;
 
     vsrc = load8888(src);
     vsrca = expand_alpha(vsrc);
@@ -2315,9 +2328,10 @@ fbCompositeIn_nx8x8mmx (pixman_operator_t	op,
     }
 
     _mm_empty();
+    return 0;
 }
 
-void
+int
 fbCompositeIn_8x8mmx (pixman_operator_t	op,
 		      PicturePtr pSrc,
 		      PicturePtr pMask,
@@ -2379,9 +2393,10 @@ fbCompositeIn_8x8mmx (pixman_operator_t	op,
     }
 
     _mm_empty ();
+    return 0;
 }
 
-void
+int
 fbCompositeSrcAdd_8888x8x8mmx (pixman_operator_t   op,
 			       PicturePtr pSrc,
 			       PicturePtr pMask,
@@ -2410,7 +2425,7 @@ fbCompositeSrcAdd_8888x8x8mmx (pixman_operator_t   op,
 
     sa = src >> 24;
     if (sa == 0)
-	return;
+	return 0;
 
     vsrc = load8888(src);
     vsrca = expand_alpha(vsrc);
@@ -2457,9 +2472,10 @@ fbCompositeSrcAdd_8888x8x8mmx (pixman_operator_t   op,
     }
 
     _mm_empty();
+    return 0;
 }
 
-void
+int
 fbCompositeSrcAdd_8000x8000mmx (pixman_operator_t	op,
 				PicturePtr pSrc,
 				PicturePtr pMask,
@@ -2529,9 +2545,10 @@ fbCompositeSrcAdd_8000x8000mmx (pixman_operator_t	op,
     }
 
     _mm_empty();
+    return 0;
 }
 
-void
+int
 fbCompositeSrcAdd_8888x8888mmx (pixman_operator_t		op,
 				PicturePtr	pSrc,
 				PicturePtr	pMask,
@@ -2589,6 +2606,7 @@ fbCompositeSrcAdd_8888x8888mmx (pixman_operator_t		op,
     }
 
     _mm_empty();
+    return 0;
 }
 
 Bool
@@ -2813,7 +2831,7 @@ fbCopyAreammx (FbPixels	*pSrc,
     return TRUE;
 }
 
-void
+int
 fbCompositeCopyAreammx (pixman_operator_t		op,
 			PicturePtr	pSrc,
 			PicturePtr	pMask,
@@ -2827,11 +2845,11 @@ fbCompositeCopyAreammx (pixman_operator_t		op,
 			CARD16		width,
 			CARD16		height)
 {
-    fbCopyAreammx (pSrc->pDrawable,
-		   pDst->pDrawable,
-		   xSrc, ySrc,
-		   xDst, yDst,
-		   width, height);
+    return !fbCopyAreammx (pSrc->pDrawable,
+		          pDst->pDrawable,
+		          xSrc, ySrc,
+		          xDst, yDst,
+		          width, height);
 }
 
 #endif /* RENDER */
diff --git a/pixman/src/fbmmx.h b/pixman/src/fbmmx.h
index 054ac0b..54c9619 100644
--- a/pixman/src/fbmmx.h
+++ b/pixman/src/fbmmx.h
@@ -45,73 +45,21 @@ pixman_private
 void fbComposeSetupMMX(void);
 
 pixman_private
-void fbCompositeIn_nx8x8mmx (pixman_operator_t	op,
-			     PicturePtr pSrc,
-			     PicturePtr pMask,
-			     PicturePtr pDst,
-			     INT16      xSrc,
-			     INT16      ySrc,
-			     INT16      xMask,
-			     INT16      yMask,
-			     INT16      xDst,
-			     INT16      yDst,
-			     CARD16     width,
-			     CARD16     height);
+int fbCompositeIn_nx8x8mmx (pixman_operator_t	op,
+			    PicturePtr pSrc,
+			    PicturePtr pMask,
+			    PicturePtr pDst,
+			    INT16      xSrc,
+			    INT16      ySrc,
+			    INT16      xMask,
+			    INT16      yMask,
+			    INT16      xDst,
+			    INT16      yDst,
+			    CARD16     width,
+			    CARD16     height);
 
 pixman_private
-void fbCompositeSolidMask_nx8888x0565Cmmx (pixman_operator_t      op,
-					   PicturePtr pSrc,
-					   PicturePtr pMask,
-					   PicturePtr pDst,
-					   INT16      xSrc,
-					   INT16      ySrc,
-					   INT16      xMask,
-					   INT16      yMask,
-					   INT16      xDst,
-					   INT16      yDst,
-					   CARD16     width,
-					   CARD16     height);
-pixman_private
-void fbCompositeSrcAdd_8888x8888mmx (pixman_operator_t	op,
-				     PicturePtr	pSrc,
-				     PicturePtr	pMask,
-				     PicturePtr	pDst,
-				     INT16	xSrc,
-				     INT16      ySrc,
-				     INT16      xMask,
-				     INT16      yMask,
-				     INT16      xDst,
-				     INT16      yDst,
-				     CARD16     width,
-				     CARD16     height);
-pixman_private
-void fbCompositeSolidMask_nx8888x8888Cmmx (pixman_operator_t	op,
-					   PicturePtr	pSrc,
-					   PicturePtr	pMask,
-					   PicturePtr	pDst,
-					   INT16	xSrc,
-					   INT16	ySrc,
-					   INT16	xMask,
-					   INT16	yMask,
-					   INT16	xDst,
-					   INT16	yDst,
-					   CARD16	width,
-					   CARD16	height);
-pixman_private
-void fbCompositeSolidMask_nx8x8888mmx (pixman_operator_t      op,
-				       PicturePtr pSrc,
-				       PicturePtr pMask,
-				       PicturePtr pDst,
-				       INT16      xSrc,
-				       INT16      ySrc,
-				       INT16      xMask,
-				       INT16      yMask,
-				       INT16      xDst,
-				       INT16      yDst,
-				       CARD16     width,
-				       CARD16     height);
-pixman_private
-void fbCompositeSolidMaskSrc_nx8x8888mmx (pixman_operator_t      op,
+int fbCompositeSolidMask_nx8888x0565Cmmx (pixman_operator_t      op,
 					  PicturePtr pSrc,
 					  PicturePtr pMask,
 					  PicturePtr pDst,
@@ -123,9 +71,89 @@ void fbCompositeSolidMaskSrc_nx8x8888mmx (pixman_operator_t      op,
 					  INT16      yDst,
 					  CARD16     width,
 					  CARD16     height);
+pixman_private
+int fbCompositeSrcAdd_8888x8888mmx (pixman_operator_t	op,
+				    PicturePtr	pSrc,
+				    PicturePtr	pMask,
+				    PicturePtr	pDst,
+				    INT16	xSrc,
+				    INT16      ySrc,
+				    INT16      xMask,
+				    INT16      yMask,
+				    INT16      xDst,
+				    INT16      yDst,
+				    CARD16     width,
+				    CARD16     height);
+pixman_private
+int fbCompositeSolidMask_nx8888x8888Cmmx (pixman_operator_t	op,
+					  PicturePtr	pSrc,
+					  PicturePtr	pMask,
+					  PicturePtr	pDst,
+					  INT16	xSrc,
+					  INT16	ySrc,
+					  INT16	xMask,
+					  INT16	yMask,
+					  INT16	xDst,
+					  INT16	yDst,
+					  CARD16	width,
+					  CARD16	height);
+pixman_private
+int fbCompositeSolidMask_nx8x8888mmx (pixman_operator_t      op,
+				      PicturePtr pSrc,
+				      PicturePtr pMask,
+				      PicturePtr pDst,
+				      INT16      xSrc,
+				      INT16      ySrc,
+				      INT16      xMask,
+				      INT16      yMask,
+				      INT16      xDst,
+				      INT16      yDst,
+				      CARD16     width,
+				      CARD16     height);
+pixman_private
+int fbCompositeSolidMaskSrc_nx8x8888mmx (pixman_operator_t      op,
+					 PicturePtr pSrc,
+					 PicturePtr pMask,
+					 PicturePtr pDst,
+					 INT16      xSrc,
+					 INT16      ySrc,
+					 INT16      xMask,
+					 INT16      yMask,
+					 INT16      xDst,
+					 INT16      yDst,
+					 CARD16     width,
+					 CARD16     height);
+
+pixman_private
+int fbCompositeSrcAdd_8888x8x8mmx (pixman_operator_t   op,
+				   PicturePtr pSrc,
+				   PicturePtr pMask,
+				   PicturePtr pDst,
+				   INT16      xSrc,
+				   INT16      ySrc,
+				   INT16      xMask,
+				   INT16      yMask,
+				   INT16      xDst,
+				   INT16      yDst,
+				   CARD16     width,
+				   CARD16     height);
+
+pixman_private
+int fbCompositeIn_8x8mmx (pixman_operator_t	op,
+			  PicturePtr pSrc,
+			  PicturePtr pMask,
+			  PicturePtr pDst,
+			  INT16      xSrc,
+			  INT16      ySrc,
+			  INT16      xMask,
+			  INT16      yMask,
+			  INT16      xDst,
+			  INT16      yDst,
+			  CARD16     width,
+			  CARD16     height);
 
 pixman_private
-void fbCompositeSrcAdd_8888x8x8mmx (pixman_operator_t   op,
+int fbCompositeSrcAdd_8000x8000mmx (pixman_operator_t	op,
 				    PicturePtr pSrc,
 				    PicturePtr pMask,
 				    PicturePtr pDst,
@@ -137,151 +165,123 @@ void fbCompositeSrcAdd_8888x8x8mmx (pixman_operator_t   op,
 				    INT16      yDst,
 				    CARD16     width,
 				    CARD16     height);
-
-pixman_private
-void fbCompositeIn_8x8mmx (pixman_operator_t	op,
-			   PicturePtr pSrc,
-			   PicturePtr pMask,
-			   PicturePtr pDst,
-			   INT16      xSrc,
-			   INT16      ySrc,
-			   INT16      xMask,
-			   INT16      yMask,
-			   INT16      xDst,
-			   INT16      yDst,
-			   CARD16     width,
-			   CARD16     height);
-
 pixman_private
-void fbCompositeSrcAdd_8000x8000mmx (pixman_operator_t	op,
-				     PicturePtr pSrc,
-				     PicturePtr pMask,
-				     PicturePtr pDst,
-				     INT16      xSrc,
-				     INT16      ySrc,
-				     INT16      xMask,
-				     INT16      yMask,
-				     INT16      xDst,
-				     INT16      yDst,
-				     CARD16     width,
-				     CARD16     height);
+int fbCompositeSrc_8888RevNPx8888mmx (pixman_operator_t      op,
+				      PicturePtr pSrc,
+				      PicturePtr pMask,
+				      PicturePtr pDst,
+				      INT16      xSrc,
+				      INT16      ySrc,
+				      INT16      xMask,
+				      INT16      yMask,
+				      INT16      xDst,
+				      INT16      yDst,
+				      CARD16     width,
+				      CARD16     height);
 pixman_private
-void fbCompositeSrc_8888RevNPx8888mmx (pixman_operator_t      op,
-				       PicturePtr pSrc,
-				       PicturePtr pMask,
-				       PicturePtr pDst,
-				       INT16      xSrc,
-				       INT16      ySrc,
-				       INT16      xMask,
-				       INT16      yMask,
-				       INT16      xDst,
-				       INT16      yDst,
-				       CARD16     width,
-				       CARD16     height);
+int fbCompositeSrc_8888x0565mmx (pixman_operator_t      op,
+				 PicturePtr pSrc,
+				 PicturePtr pMask,
+				 PicturePtr pDst,
+				 INT16      xSrc,
+				 INT16      ySrc,
+				 INT16      xMask,
+				 INT16      yMask,
+				 INT16      xDst,
+				 INT16      yDst,
+				 CARD16     width,
+				 CARD16     height);
 pixman_private
-void fbCompositeSrc_8888x0565mmx (pixman_operator_t      op,
-				  PicturePtr pSrc,
-				  PicturePtr pMask,
-				  PicturePtr pDst,
-				  INT16      xSrc,
-				  INT16      ySrc,
-				  INT16      xMask,
-				  INT16      yMask,
-				  INT16      xDst,
-				  INT16      yDst,
-				  CARD16     width,
-				  CARD16     height);
+int fbCompositeSrc_8888RevNPx0565mmx (pixman_operator_t      op,
+				      PicturePtr pSrc,
+				      PicturePtr pMask,
+				      PicturePtr pDst,
+				      INT16      xSrc,
+				      INT16      ySrc,
+				      INT16      xMask,
+				      INT16      yMask,
+				      INT16      xDst,
+				      INT16      yDst,
+				      CARD16     width,
+				      CARD16     height);
 pixman_private
-void fbCompositeSrc_8888RevNPx0565mmx (pixman_operator_t      op,
-				       PicturePtr pSrc,
-				       PicturePtr pMask,
-				       PicturePtr pDst,
-				       INT16      xSrc,
-				       INT16      ySrc,
-				       INT16      xMask,
-				       INT16      yMask,
-				       INT16      xDst,
-				       INT16      yDst,
-				       CARD16     width,
-				       CARD16     height);
+int fbCompositeSolid_nx8888mmx (pixman_operator_t		op,
+				PicturePtr	pSrc,
+				PicturePtr	pMask,
+				PicturePtr	pDst,
+				INT16		xSrc,
+				INT16		ySrc,
+				INT16		xMask,
+				INT16		yMask,
+				INT16		xDst,
+				INT16		yDst,
+				CARD16		width,
+				CARD16		height);
 pixman_private
-void fbCompositeSolid_nx8888mmx (pixman_operator_t		op,
-				 PicturePtr	pSrc,
-				 PicturePtr	pMask,
-				 PicturePtr	pDst,
-				 INT16		xSrc,
-				 INT16		ySrc,
-				 INT16		xMask,
-				 INT16		yMask,
-				 INT16		xDst,
-				 INT16		yDst,
-				 CARD16		width,
-				 CARD16		height);
+int fbCompositeSolid_nx0565mmx (pixman_operator_t		op,
+				PicturePtr	pSrc,
+				PicturePtr	pMask,
+				PicturePtr	pDst,
+				INT16		xSrc,
+				INT16		ySrc,
+				INT16		xMask,
+				INT16		yMask,
+				INT16		xDst,
+				INT16		yDst,
+				CARD16		width,
+				CARD16		height);
 pixman_private
-void fbCompositeSolid_nx0565mmx (pixman_operator_t		op,
-				 PicturePtr	pSrc,
-				 PicturePtr	pMask,
-				 PicturePtr	pDst,
-				 INT16		xSrc,
-				 INT16		ySrc,
-				 INT16		xMask,
-				 INT16		yMask,
-				 INT16		xDst,
-				 INT16		yDst,
-				 CARD16		width,
-				 CARD16		height);
+int fbCompositeSolidMask_nx8x0565mmx (pixman_operator_t      op,
+				      PicturePtr pSrc,
+				      PicturePtr pMask,
+				      PicturePtr pDst,
+				      INT16      xSrc,
+				      INT16      ySrc,
+				      INT16      xMask,
+				      INT16      yMask,
+				      INT16      xDst,
+				      INT16      yDst,
+				      CARD16     width,
+				      CARD16     height);
 pixman_private
-void fbCompositeSolidMask_nx8x0565mmx (pixman_operator_t      op,
-				       PicturePtr pSrc,
-				       PicturePtr pMask,
-				       PicturePtr pDst,
-				       INT16      xSrc,
-				       INT16      ySrc,
-				       INT16      xMask,
-				       INT16      yMask,
-				       INT16      xDst,
-				       INT16      yDst,
-				       CARD16     width,
-				       CARD16     height);
+int fbCompositeSrc_x888x8x8888mmx (pixman_operator_t	op,
+				   PicturePtr  pSrc,
+				   PicturePtr  pMask,
+				   PicturePtr  pDst,
+				   INT16	xSrc,
+				   INT16	ySrc,
+				   INT16       xMask,
+				   INT16       yMask,
+				   INT16       xDst,
+				   INT16       yDst,
+				   CARD16      width,
+				   CARD16      height);
 pixman_private
-void fbCompositeSrc_x888x8x8888mmx (pixman_operator_t	op,
-				    PicturePtr  pSrc,
-				    PicturePtr  pMask,
-				    PicturePtr  pDst,
-				    INT16	xSrc,
-				    INT16	ySrc,
-				    INT16       xMask,
-				    INT16       yMask,
-				    INT16       xDst,
-				    INT16       yDst,
-				    CARD16      width,
-				    CARD16      height);
-pixman_private
-void fbCompositeSrc_8888x8x8888mmx (pixman_operator_t	op,
-				    PicturePtr  pSrc,
-				    PicturePtr  pMask,
-				    PicturePtr  pDst,
-				    INT16	xSrc,
-				    INT16	ySrc,
-				    INT16       xMask,
-				    INT16       yMask,
-				    INT16       xDst,
-				    INT16       yDst,
-				    CARD16      width,
-				    CARD16      height);
+int fbCompositeSrc_8888x8x8888mmx (pixman_operator_t	op,
+				   PicturePtr  pSrc,
+				   PicturePtr  pMask,
+				   PicturePtr  pDst,
+				   INT16	xSrc,
+				   INT16	ySrc,
+				   INT16       xMask,
+				   INT16       yMask,
+				   INT16       xDst,
+				   INT16       yDst,
+				   CARD16      width,
+				   CARD16      height);
 pixman_private
-void fbCompositeSrc_8888x8888mmx (pixman_operator_t      op,
-				  PicturePtr pSrc,
-				  PicturePtr pMask,
-				  PicturePtr pDst,
-				  INT16      xSrc,
-				  INT16      ySrc,
-				  INT16      xMask,
-				  INT16      yMask,
-				  INT16      xDst,
-				  INT16      yDst,
-				  CARD16     width,
-				  CARD16     height);
+int fbCompositeSrc_8888x8888mmx (pixman_operator_t      op,
+				 PicturePtr pSrc,
+				 PicturePtr pMask,
+				 PicturePtr pDst,
+				 INT16      xSrc,
+				 INT16      ySrc,
+				 INT16      xMask,
+				 INT16      yMask,
+				 INT16      xDst,
+				 INT16      yDst,
+				 CARD16     width,
+				 CARD16     height);
 pixman_private
 Bool fbCopyAreammx (FbPixels	*pSrc,
 		    FbPixels	*pDst,
@@ -293,18 +293,18 @@ Bool fbCopyAreammx (FbPixels	*pSrc,
 		    int		height);
 
 pixman_private
-void fbCompositeCopyAreammx (pixman_operator_t	op,
-			     PicturePtr	pSrc,
-			     PicturePtr	pMask,
-			     PicturePtr	pDst,
-			     INT16	xSrc,
-			     INT16      ySrc,
-			     INT16      xMask,
-			     INT16      yMask,
-			     INT16      xDst,
-			     INT16      yDst,
-			     CARD16     width,
-			     CARD16     height);
+int fbCompositeCopyAreammx (pixman_operator_t	op,
+			    PicturePtr	pSrc,
+			    PicturePtr	pMask,
+			    PicturePtr	pDst,
+			    INT16	xSrc,
+			    INT16      ySrc,
+			    INT16      xMask,
+			    INT16      yMask,
+			    INT16      xDst,
+			    INT16      yDst,
+			    CARD16     width,
+			    CARD16     height);
 
 pixman_private
 Bool fbSolidFillmmx (FbPixels	*pDraw,
diff --git a/pixman/src/fbpict.c b/pixman/src/fbpict.c
index 0bd989f..4d07699 100644
--- a/pixman/src/fbpict.c
+++ b/pixman/src/fbpict.c
@@ -133,7 +133,7 @@ fbIn (CARD32 x, CARD8 y)
  *  opSRCxMASKxDST
  */
 
-static void
+static int
 fbCompositeSolidMask_nx8x8888 (pixman_operator_t   op,
 			       PicturePtr pSrc,
 			       PicturePtr pMask,
@@ -158,7 +158,7 @@ fbCompositeSolidMask_nx8x8888 (pixman_operator_t   op,
     dstMask = FbFullMask (pDst->pDrawable->depth);
     srca = src >> 24;
     if (src == 0)
-	return;
+	return 0;
 
     fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
     fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
@@ -189,9 +189,10 @@ fbCompositeSolidMask_nx8x8888 (pixman_operator_t   op,
 	    dst++;
 	}
     }
+    return 0;
 }
 
-static void
+static int
 fbCompositeSolidMask_nx8888x8888C (pixman_operator_t   op,
 				   PicturePtr pSrc,
 				   PicturePtr pMask,
@@ -217,7 +218,7 @@ fbCompositeSolidMask_nx8888x8888C (pixman_operator_t   op,
     dstMask = FbFullMask (pDst->pDrawable->depth);
     srca = src >> 24;
     if (src == 0)
-	return;
+	return 0;
 
     fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
     fbComposeGetStart (pMask, xMask, yMask, CARD32, maskStride, maskLine, 1);
@@ -262,10 +263,12 @@ fbCompositeSolidMask_nx8888x8888C (pixman_operator_t   op,
 	    dst++;
 	}
     }
+
+    return 0;
 }
 
 #define srcAlphaCombine24(a,b) genericCombine24(a,b,srca,srcia)
-static void
+static int
 fbCompositeSolidMask_nx8x0888 (pixman_operator_t   op,
 			       PicturePtr pSrc,
 			       PicturePtr pMask,
@@ -291,7 +294,7 @@ fbCompositeSolidMask_nx8x0888 (pixman_operator_t   op,
     srca = src >> 24;
     srcia = 255-srca;
     if (src == 0)
-	return;
+	return 0;
 
 	rs=src&0xff;
 	gs=(src>>8)&0xff;
@@ -358,9 +361,11 @@ fbCompositeSolidMask_nx8x0888 (pixman_operator_t   op,
 			}
 		}
 	}
+
+    return 0;
 }
 
-static void
+static int
 fbCompositeSolidMask_nx8x0565 (pixman_operator_t      op,
 				  PicturePtr pSrc,
 				  PicturePtr pMask,
@@ -385,7 +390,7 @@ fbCompositeSolidMask_nx8x0565 (pixman_operator_t      op,
     fbComposeGetSolid(pSrc, pDst, src);
 
     if (src == 0)
-	return;
+	return 0;
 
     srca8 = (src >> 24);
     srca5 = (srca8 >> 3);
@@ -435,9 +440,11 @@ fbCompositeSolidMask_nx8x0565 (pixman_operator_t      op,
 	    }
 	}
     }
+
+    return 0;
 }
 
-static void
+static int
 fbCompositeSolidMask_nx8888x0565 (pixman_operator_t      op,
 				  PicturePtr pSrc,
 				  PicturePtr pMask,
@@ -463,7 +470,7 @@ fbCompositeSolidMask_nx8888x0565 (pixman_operator_t      op,
     fbComposeGetSolid(pSrc, pDst, src);
 
     if (src == 0)
-	return;
+	return 0;
 
     srca8 = src >> 24;
     srca5 = srca8 >> 3;
@@ -514,9 +521,11 @@ fbCompositeSolidMask_nx8888x0565 (pixman_operator_t      op,
 	    }
 	}
     }
+
+    return 0;
 }
 
-static void
+static int
 fbCompositeSolidMask_nx8888x0565C (pixman_operator_t      op,
 				   PicturePtr pSrc,
 				   PicturePtr pMask,
@@ -543,7 +552,7 @@ fbCompositeSolidMask_nx8888x0565C (pixman_operator_t      op,
 
     srca = src >> 24;
     if (src == 0)
-	return;
+	return 0;
 
     src16 = cvt8888to0565(src);
 
@@ -587,9 +596,11 @@ fbCompositeSolidMask_nx8888x0565C (pixman_operator_t      op,
 	    dst++;
 	}
     }
+
+    return 0;
 }
 
-static void
+static int
 fbCompositeSrc_8888x8888 (pixman_operator_t  op,
 			 PicturePtr pSrc,
 			 PicturePtr pMask,
@@ -633,9 +644,11 @@ fbCompositeSrc_8888x8888 (pixman_operator_t  op,
 	    dst++;
 	}
     }
+
+    return 0;
 }
 
-static void
+static int
 fbCompositeSrc_8888x0888 (pixman_operator_t  op,
 			 PicturePtr pSrc,
 			 PicturePtr pMask,
@@ -682,9 +695,11 @@ fbCompositeSrc_8888x0888 (pixman_operator_t  op,
 	    dst += 3;
 	}
     }
+
+    return 0;
 }
 
-static void
+static int
 fbCompositeSrc_8888x0565 (pixman_operator_t  op,
 			 PicturePtr pSrc,
 			 PicturePtr pMask,
@@ -734,9 +749,11 @@ fbCompositeSrc_8888x0565 (pixman_operator_t  op,
 	    dst++;
 	}
     }
+
+    return 0;
 }
 
-static void
+static int
 fbCompositeSrcAdd_8000x8000 (pixman_operator_t	  op,
 			     PicturePtr pSrc,
 			     PicturePtr pMask,
@@ -784,9 +801,11 @@ fbCompositeSrcAdd_8000x8000 (pixman_operator_t	  op,
 	    dst++;
 	}
     }
+
+    return 0;
 }
 
-static void
+static int
 fbCompositeSrcAdd_8888x8888 (pixman_operator_t   op,
 			     PicturePtr pSrc,
 			     PicturePtr pMask,
@@ -841,9 +860,11 @@ fbCompositeSrcAdd_8888x8888 (pixman_operator_t   op,
 	    dst++;
 	}
     }
+
+    return 0;
 }
 
-static void
+static int
 fbCompositeSrcAdd_8888x8x8 (pixman_operator_t   op,
 			    PicturePtr pSrc,
 			    PicturePtr pMask,
@@ -893,9 +914,11 @@ fbCompositeSrcAdd_8888x8x8 (pixman_operator_t   op,
 	    *dst++ = r;
 	}
     }
+
+    return 0;
 }
 
-static void
+static int
 fbCompositeSrcAdd_1000x1000 (pixman_operator_t   op,
 			     PicturePtr pSrc,
 			     PicturePtr pMask,
@@ -936,9 +959,11 @@ fbCompositeSrcAdd_1000x1000 (pixman_operator_t   op,
 
 	   FALSE,
 	   FALSE);
+
+    return 0;
 }
 
-static void
+static int
 fbCompositeSolidMask_nx1xn (pixman_operator_t   op,
 			    PicturePtr pSrc,
 			    PicturePtr pMask,
@@ -964,10 +989,9 @@ fbCompositeSolidMask_nx1xn (pixman_operator_t   op,
 
     if ((src & 0xff000000) != 0xff000000)
     {
-	pixman_compositeGeneral  (op, pSrc, pMask, pDst,
+	return pixman_compositeGeneral  (op, pSrc, pMask, pDst,
 			     xSrc, ySrc, xMask, yMask, xDst, yDst,
 			     width, height);
-	return;
     }
     FbGetStipPixels (pMask->pixels, maskBits, maskStride, maskBpp, maskXoff, maskYoff);
     fbGetDrawable (pDst->pDrawable, dstBits, dstStride, dstBpp, dstXoff, dstYoff);
@@ -1000,10 +1024,12 @@ fbCompositeSolidMask_nx1xn (pixman_operator_t   op,
 	      src,
 	      FB_ALLONES,
 	      0x0);
+
+    return 0;
 }
 
 /* prototype to help with merging */
-static void
+static int
 fbCompositeSrcSrc_nxn  (pixman_operator_t	op,
 			PicturePtr pSrc,
 			PicturePtr pMask,
@@ -1019,7 +1045,7 @@ fbCompositeSrcSrc_nxn  (pixman_operator_t	op,
 /*
  * Apply a constant alpha value in an over computation
  */
-static void
+static int
 fbCompositeTrans_0565xnx0565(pixman_operator_t      op,
 			     PicturePtr pSrc,
 			     PicturePtr pMask,
@@ -1046,13 +1072,12 @@ fbCompositeTrans_0565xnx0565(pixman_operator_t      op,
     maskAlpha = mask >> 27;
 
     if (!maskAlpha)
-	return;
+	return 0;
     if (maskAlpha == 0xff)
     {
-	fbCompositeSrcSrc_nxn (PIXMAN_OPERATOR_SRC, pSrc, pMask, pDst,
-			       xSrc, ySrc, xMask, yMask, xDst, yDst,
-			       width, height);
-	return;
+	return fbCompositeSrcSrc_nxn (PIXMAN_OPERATOR_SRC, pSrc, pMask, pDst,
+			              xSrc, ySrc, xMask, yMask, xDst, yDst,
+				      width, height);
     }
 
     fbComposeGetStart (pSrc, xSrc, ySrc, CARD16, srcStride, srcLine, 1);
@@ -1117,11 +1142,13 @@ fbCompositeTrans_0565xnx0565(pixman_operator_t      op,
 			inOver0565(maskAlpha, s_16, d_16, *dst);
 		}
 	}
+
+    return 0;
 }
 
 /* macros for "i can't believe it's not fast" packed pixel handling */
 #define alphamaskCombine24(a,b) genericCombine24(a,b,maskAlpha,maskiAlpha)
-static void
+static int
 fbCompositeTrans_0888xnx0888(pixman_operator_t      op,
 			     PicturePtr pSrc,
 			     PicturePtr pMask,
@@ -1147,7 +1174,7 @@ fbCompositeTrans_0888xnx0888(pixman_operator_t      op,
 	maskiAlpha= 255-maskAlpha;
 
     if (!maskAlpha)
-	return;
+	return 0;
     /*
     if (maskAlpha == 0xff)
     {
@@ -1301,13 +1328,15 @@ fbCompositeTrans_0888xnx0888(pixman_operator_t      op,
 			}
 		}
 	}
+
+	return 0;
 }
 
 /*
  * Simple bitblt
  */
 
-static void
+static int
 fbCompositeSrcSrc_nxn  (pixman_operator_t	op,
 			PicturePtr pSrc,
 			PicturePtr pMask,
@@ -1351,6 +1380,7 @@ fbCompositeSrcSrc_nxn  (pixman_operator_t	op,
 
 	   reverse,
 	   upsidedown);
+    return 0;
 }
 
 /*
@@ -1375,7 +1405,7 @@ fbCompositeSolidSrc_nxn  (CARD8	op,
 
 # define mod(a,b)	((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b))
 
-void
+int
 pixman_composite (pixman_operator_t	op,
 	     PicturePtr pSrc,
 	     PicturePtr pMask,
@@ -1402,6 +1432,7 @@ pixman_composite (pixman_operator_t	op,
     Bool	    dstAlphaMap = pDst->alphaMap != 0;
     int		    x_msk, y_msk, x_src, y_src, x_dst, y_dst;
     unsigned int    w, h, w_this, h_this;
+    int ret = 1;
 
 #ifdef USE_MMX
     static Bool mmx_setup = FALSE;
@@ -1922,8 +1953,7 @@ pixman_composite (pixman_operator_t	op,
 
     if (!func) {
         /* no fast path, use the general code */
-        pixman_compositeGeneral(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, xDst, yDst, width, height);
-        return;
+        return pixman_compositeGeneral(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, xDst, yDst, width, height);
     }
 
     /* if we are transforming, we handle repeats in IcFetch[a]_transform */
@@ -1933,7 +1963,13 @@ pixman_composite (pixman_operator_t	op,
 	maskRepeat = 0;
 
     region = pixman_region_create();
-    pixman_region_union_rect (region, region, xDst, yDst, width, height);
+    if (pixman_region_union_rect (region, region,
+	       	                  xDst, yDst,
+				  width, height) !=
+	    PIXMAN_REGION_STATUS_SUCCESS) {
+	pixman_region_destroy (region);
+	return 1;
+    }
 
     if (!FbComputeCompositeRegion (region,
 				   pSrc,
@@ -1946,8 +1982,10 @@ pixman_composite (pixman_operator_t	op,
 				   xDst,
 				   yDst,
 				   width,
-				   height))
-	return;
+				   height)) {
+	pixman_region_destroy (region);
+	return 1;
+    }
 
     n = pixman_region_num_rects (region);
     pbox = pixman_region_rects (region);
@@ -1991,9 +2029,10 @@ pixman_composite (pixman_operator_t	op,
 		    if (w_this > pSrc->pDrawable->width - x_src)
 			w_this = pSrc->pDrawable->width - x_src;
 		}
-		(*func) (op, pSrc, pMask, pDst,
-			 x_src, y_src, x_msk, y_msk, x_dst, y_dst,
-			 w_this, h_this);
+		if ((*func) (op, pSrc, pMask, pDst,
+			     x_src, y_src, x_msk, y_msk, x_dst, y_dst,
+			     w_this, h_this))
+		    goto bail;
 		w -= w_this;
 		x_src += w_this;
 		x_msk += w_this;
@@ -2006,7 +2045,11 @@ pixman_composite (pixman_operator_t	op,
 	}
 	pbox++;
     }
+    ret = 0;
+bail:
     pixman_region_destroy (region);
+
+    return ret;
 }
 
 /* The CPU detection code needs to be in a file not compiled with
diff --git a/pixman/src/fbpict.h b/pixman/src/fbpict.h
index 0ff0c11..196e5e2 100644
--- a/pixman/src/fbpict.h
+++ b/pixman/src/fbpict.h
@@ -93,7 +93,7 @@
 	(bits) = FbLeftStipBits((bits),1) ? 0xff000000 : 0x00000000;\
 	break; \
     default: \
-	return; \
+	return 1; \
     } \
     /* manage missing src alpha */ \
     if ((pict)->image_format.alphaMask == 0) \
diff --git a/pixman/src/icimage.c b/pixman/src/icimage.c
index 4d957a0..62ff209 100644
--- a/pixman/src/icimage.c
+++ b/pixman/src/icimage.c
@@ -521,7 +521,14 @@ pixman_image_set_clip_region (pixman_image_t	*image,
     pixman_image_destroyClip (image);
     if (region) {
 	image->clientClip = pixman_region_create ();
-	pixman_region_copy (image->clientClip, region);
+	if (image->clientClip == NULL)
+	    return 1;
+	if (pixman_region_copy (image->clientClip, region) !=
+		PIXMAN_REGION_STATUS_SUCCESS) {
+	    pixman_region_destroy (image->clientClip);
+	    image->clientClip = NULL;
+	    return 1;
+	}
 	image->clientClipType = CT_REGION;
     }
 
@@ -529,22 +536,36 @@ pixman_image_set_clip_region (pixman_image_t	*image,
     if (image->pSourcePict)
 	return 0;
 
-    if (image->freeCompClip)
+    if (image->freeCompClip) {
 	pixman_region_destroy (image->pCompositeClip);
+	image->freeCompClip = 0;
+    }
     image->pCompositeClip = pixman_region_create();
-    pixman_region_union_rect (image->pCompositeClip, image->pCompositeClip,
-			      0, 0, image->pixels->width, image->pixels->height);
+    if (image->pCompositeClip == NULL) {
+	return 1;
+    }
+    if (pixman_region_union_rect (image->pCompositeClip, image->pCompositeClip,
+			      0, 0,
+			      image->pixels->width, image->pixels->height) !=
+	    PIXMAN_REGION_STATUS_SUCCESS) {
+	pixman_region_destroy (image->pCompositeClip);
+	image->pCompositeClip = NULL;
+	return 1;
+    }
     image->freeCompClip = 1;
     if (region) {
+	pixman_region_status_t status;
 	pixman_region_translate (image->pCompositeClip,
 				 - image->clipOrigin.x,
 				 - image->clipOrigin.y);
-	pixman_region_intersect (image->pCompositeClip,
-				 image->pCompositeClip,
-				 region);
+	status = pixman_region_intersect (image->pCompositeClip,
+				          image->pCompositeClip,
+				          region);
 	pixman_region_translate (image->pCompositeClip,
 				 image->clipOrigin.x,
 				 image->clipOrigin.y);
+	if (status != PIXMAN_REGION_STATUS_SUCCESS)
+	    return 1;
     }
 
     return 0;
@@ -558,6 +579,7 @@ FbClipImageReg (pixman_region16_t	*region,
 		int		dx,
 		int		dy)
 {
+    int ret = 1;
     if (pixman_region_num_rects (region) == 1 &&
 	pixman_region_num_rects (clip) == 1)
     {
@@ -582,10 +604,11 @@ FbClipImageReg (pixman_region16_t	*region,
     else
     {
 	pixman_region_translate (region, dx, dy);
-	pixman_region_intersect (region, clip, region);
+	ret = pixman_region_intersect (region, clip, region) ==
+	    PIXMAN_REGION_STATUS_SUCCESS;
 	pixman_region_translate (region, -dx, -dy);
     }
-    return 1;
+    return ret;
 }
 
 static __inline int
@@ -600,6 +623,7 @@ FbClipImageSrc (pixman_region16_t	*region,
     /* XXX davidr hates this, wants to never use source-based clipping */
     if (image->repeat != PIXMAN_REPEAT_NONE || image->pSourcePict)
     {
+	int ret = 1;
 	/* XXX no source clipping */
 	if (image->compositeClipSource &&
 	    image->clientClipType != CT_NONE)
@@ -607,12 +631,13 @@ FbClipImageSrc (pixman_region16_t	*region,
 	    pixman_region_translate (region,
 			   dx - image->clipOrigin.x,
 			   dy - image->clipOrigin.y);
-	    pixman_region_intersect (region, image->clientClip, region);
+	    ret = pixman_region_intersect (region, image->clientClip, region) ==
+		PIXMAN_REGION_STATUS_SUCCESS;
 	    pixman_region_translate (region,
 			   - (dx - image->clipOrigin.x),
 			   - (dy - image->clipOrigin.y));
 	}
-	return 1;
+	return ret;
     }
     else
     {
diff --git a/pixman/src/icimage.h b/pixman/src/icimage.h
index bbf41b9..f5daa31 100644
--- a/pixman/src/icimage.h
+++ b/pixman/src/icimage.h
@@ -278,7 +278,7 @@ FbCreateAlphaPicture (pixman_image_t	*dst,
 		      uint16_t	width,
 		      uint16_t	height);
 
-typedef void	(*CompositeFunc) (pixman_operator_t   op,
+typedef int	(*CompositeFunc) (pixman_operator_t   op,
 				  pixman_image_t    *iSrc,
 				  pixman_image_t    *iMask,
 				  pixman_image_t    *iDst,
@@ -367,7 +367,7 @@ fbBuildCompositeOperand (pixman_image_t	    *image,
 			 int		    transform,
 			 int		    alpha);
 
-pixman_private void
+pixman_private int
 pixman_compositeGeneral (pixman_operator_t	op,
 			 pixman_image_t	*iSrc,
 			 pixman_image_t	*iMask,
diff --git a/pixman/src/icrect.c b/pixman/src/icrect.c
index e4d0c12..fbd2a2f 100644
--- a/pixman/src/icrect.c
+++ b/pixman/src/icrect.c
@@ -176,7 +176,7 @@ pixman_fill_rect_general (pixman_image_t *dst,
     }
 }
 
-static void
+static int
 pixman_color_rects (pixman_image_t	 *dst,
 	      pixman_image_t	 *clipPict,
 	      pixman_color_t	 *color,
@@ -201,17 +201,32 @@ pixman_color_rects (pixman_image_t	 *dst,
     yoff -= dst->pixels->y;
 
     clip = pixman_region_create();
-    pixman_region_union_rect (clip, clip,
+    if (!clip)
+	return 1;
+    if (pixman_region_union_rect (clip, clip,
 			      dst->pixels->x, dst->pixels->y,
-			      dst->pixels->width, dst->pixels->height);
+			      dst->pixels->width, dst->pixels->height) !=
+	    PIXMAN_REGION_STATUS_SUCCESS){
+	pixman_region_destroy (clip);
+	return 1;
+    }
 
-    pixman_region_intersect (clip, clip, clipPict->pCompositeClip);
+    if (pixman_region_intersect (clip, clip, clipPict->pCompositeClip) !=
+	    PIXMAN_REGION_STATUS_SUCCESS) {
+	pixman_region_destroy (clip);
+	return 1;
+    }
     if (clipPict->alphaMap)
     {
 	pixman_region_translate (clip,
 				 -clipPict->alphaOrigin.x,
 				 -clipPict->alphaOrigin.y);
-	pixman_region_intersect (clip, clip, clipPict->alphaMap->pCompositeClip);
+	if (pixman_region_intersect (clip, clip,
+		                     clipPict->alphaMap->pCompositeClip) !=
+		PIXMAN_REGION_STATUS_SUCCESS) {
+	    pixman_region_destroy (clip);
+	    return 1;
+	}
 	pixman_region_translate (clip,
 				 clipPict->alphaOrigin.x,
 				 clipPict->alphaOrigin.y);
@@ -227,14 +242,28 @@ pixman_color_rects (pixman_image_t	 *dst,
     }
 
     rects_as_region = pixman_region_create ();
+    if (!rects_as_region) {
+	pixman_region_destroy (clip);
+	return 1;
+    }
     for (i = 0; i < nRect; i++)
     {
-	pixman_region_union_rect (rects_as_region, rects_as_region,
+	if (pixman_region_union_rect (rects_as_region, rects_as_region,
 				  rects[i].x, rects[i].y,
-				  rects[i].width, rects[i].height);
+				  rects[i].width, rects[i].height) !=
+		PIXMAN_REGION_STATUS_SUCCESS) {
+	    pixman_region_destroy (rects_as_region);
+	    pixman_region_destroy (clip);
+	    return 1;
+	}
     }
 
-    pixman_region_intersect (rects_as_region, rects_as_region, clip);
+    if (pixman_region_intersect (rects_as_region, rects_as_region, clip) !=
+	    PIXMAN_REGION_STATUS_SUCCESS) {
+	pixman_region_destroy (rects_as_region);
+	pixman_region_destroy (clip);
+	return 1;
+    }
     pixman_region_destroy (clip);
 
     n_clipped_rects = pixman_region_num_rects (rects_as_region);
@@ -268,9 +297,10 @@ pixman_color_rects (pixman_image_t	 *dst,
 	    rects[i].y += yoff;
 	}
     }
+    return 0;
 }
 
-void pixman_fill_rectangle (pixman_operator_t	op,
+int pixman_fill_rectangle (pixman_operator_t	op,
 		      pixman_image_t		*dst,
 		      const pixman_color_t	*color,
 		      int		x,
@@ -285,10 +315,10 @@ void pixman_fill_rectangle (pixman_operator_t	op,
     rect.width = width;
     rect.height = height;
 
-    pixman_fill_rectangles (op, dst, color, &rect, 1);
+    return pixman_fill_rectangles (op, dst, color, &rect, 1);
 }
 
-void
+int
 pixman_fill_rectangles (pixman_operator_t		op,
 		  pixman_image_t		*dst,
 		  const pixman_color_t		*color,
@@ -296,6 +326,7 @@ pixman_fill_rectangles (pixman_operator_t		op,
 		  int			nRects)
 {
     pixman_color_t color_s = *color;
+    int ret = 1;
 
     if (color_s.alpha == 0xffff)
     {
@@ -309,12 +340,21 @@ pixman_fill_rectangles (pixman_operator_t		op,
     {
       /* We cast away the constness of rects here, because pixman_color_rects
 	 temporarily modifies it */
-	pixman_color_rects (dst, dst, &color_s, nRects, (pixman_rectangle_t *)rects, 0, 0);
-	if (dst->alphaMap)
-	    pixman_color_rects (dst->alphaMap, dst,
-			  &color_s, nRects, (pixman_rectangle_t *)rects,
-			  dst->alphaOrigin.x,
-			  dst->alphaOrigin.y);
+	if (pixman_color_rects (dst, dst,
+		                &color_s, nRects,
+				(pixman_rectangle_t *)rects, 0, 0)) {
+		goto bail1;
+	}
+	if (dst->alphaMap) {
+	    if (pixman_color_rects (dst->alphaMap, dst,
+			            &color_s, nRects,
+				    (pixman_rectangle_t *)rects,
+				    dst->alphaOrigin.x,
+				    dst->alphaOrigin.y))
+		goto bail1;
+	}
+
+	ret = 0;
     }
     else
     {
@@ -348,18 +388,22 @@ pixman_fill_rectangles (pixman_operator_t		op,
 
 	while (nRects--)
 	{
-	    pixman_composite (op, src, NULL, dst, 0, 0, 0, 0,
-			 rects->x,
-			 rects->y,
-			 rects->width,
-			 rects->height);
+	    if (pixman_composite (op, src, NULL, dst, 0, 0, 0, 0,
+			          rects->x,
+			          rects->y,
+			          rects->width,
+			          rects->height))
+		goto bail3;
 	    rects++;
 	}
 
+	ret = 0;
+bail3:
 	pixman_image_destroy (src);
 bail2:
 	FbPixelsDestroy (pixels);
-bail1:
-	;
     }
+
+bail1:
+    return ret;
 }
diff --git a/pixman/src/ictrap.c b/pixman/src/ictrap.c
index 5a33ab8..fc093f0 100644
--- a/pixman/src/ictrap.c
+++ b/pixman/src/ictrap.c
@@ -98,10 +98,7 @@ pixman_trapezoid_bounds (int ntrap, const pixman_trapezoid_t *traps, pixman_box1
     }
 }
 
-/* XXX: There are failure cases in this function. Don't we need to
- * propagate the errors out?
- */
-void
+int
 pixman_composite_trapezoids (pixman_operator_t	      op,
 			     pixman_image_t	      *src,
 			     pixman_image_t	      *dst,
@@ -116,9 +113,10 @@ pixman_composite_trapezoids (pixman_operator_t	      op,
     int16_t		xDst, yDst;
     int16_t		xRel, yRel;
     pixman_format_t	*format;
+    int ret = 0;
 
     if (ntraps == 0)
-	return;
+	return 0;
 
     /*
      * Check for solid alpha add
@@ -127,7 +125,7 @@ pixman_composite_trapezoids (pixman_operator_t	      op,
     {
 	for (; ntraps; ntraps--, traps++)
 	    fbRasterizeTrapezoid (dst, traps, 0, 0);
-	return;
+	return 0;
     }
 
     xDst = traps[0].left.p1.x >> 16;
@@ -146,8 +144,17 @@ pixman_composite_trapezoids (pixman_operator_t	      op,
     dst_bounds.y2 = pixman_image_get_height (dst);
 
     dst_region = pixman_region_create_simple (&dst_bounds);
+    if (!dst_region) {
+	pixman_region_destroy (traps_region);
+	return 1;
+    }
 
-    pixman_region_intersect (traps_region, traps_region, dst_region);
+    if (pixman_region_intersect (traps_region, traps_region, dst_region) !=
+	    PIXMAN_REGION_STATUS_SUCCESS) {
+	pixman_region_destroy (traps_region);
+	pixman_region_destroy (dst_region);
+	return 1;
+    }
 
     bounds = *(pixman_region_extents (traps_region));
 
@@ -155,11 +162,11 @@ pixman_composite_trapezoids (pixman_operator_t	      op,
     pixman_region_destroy (dst_region);
 
     if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
-	return;
+	return 0;
 
     format = pixman_format_create (PIXMAN_FORMAT_NAME_A8);
     if (!format)
-	return;
+	return 1;
 
     image = FbCreateAlphaPicture (dst, format,
 				  bounds.x2 - bounds.x1,
@@ -167,7 +174,7 @@ pixman_composite_trapezoids (pixman_operator_t	      op,
     if (!image)
     {
 	pixman_format_destroy (format);
-	return;
+	return 1;
     }
 
     for (; ntraps; ntraps--, traps++)
@@ -180,13 +187,15 @@ pixman_composite_trapezoids (pixman_operator_t	      op,
 
     xRel = bounds.x1 + xSrc - xDst;
     yRel = bounds.y1 + ySrc - yDst;
-    pixman_composite (op, src, image, dst,
-		      xRel, yRel, 0, 0, bounds.x1, bounds.y1,
-		      bounds.x2 - bounds.x1,
-		      bounds.y2 - bounds.y1);
+    ret = pixman_composite (op, src, image, dst,
+		            xRel, yRel, 0, 0, bounds.x1, bounds.y1,
+			    bounds.x2 - bounds.x1,
+			    bounds.y2 - bounds.y1);
     pixman_image_destroy (image);
 
     pixman_format_destroy (format);
+
+    return ret;
 }
 
 void
diff --git a/pixman/src/ictri.c b/pixman/src/ictri.c
index 4080239..35f983b 100644
--- a/pixman/src/ictri.c
+++ b/pixman/src/ictri.c
@@ -134,7 +134,7 @@ FbRasterizeTriangle (pixman_image_t		*image,
 	fbRasterizeTrapezoid (image, &trap[1], x_off, y_off);
 }
 
-void
+int
 pixman_composite_triangles (pixman_operator_t	op,
 		      pixman_image_t		*src,
 		      pixman_image_t		*dst,
@@ -148,6 +148,7 @@ pixman_composite_triangles (pixman_operator_t	op,
     int		xDst, yDst;
     int		xRel, yRel;
     pixman_format_t	*format;
+    int ret = 0;
 
     xDst = tris[0].p1.x >> 16;
     yDst = tris[0].p1.y >> 16;
@@ -158,13 +159,13 @@ pixman_composite_triangles (pixman_operator_t	op,
     {
 	pixman_triangle_bounds (ntris, tris, &bounds);
 	if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1)
-	    return;
+	    return 0;
 	image = FbCreateAlphaPicture (dst,
 				      format,
 				      bounds.x2 - bounds.x1,
 				      bounds.y2 - bounds.y1);
 	if (!image)
-	    return;
+	    return 1;
     }
     for (; ntris; ntris--, tris++)
     {
@@ -177,18 +178,23 @@ pixman_composite_triangles (pixman_operator_t	op,
 					  format,
 					  bounds.x2 - bounds.x1,
 					  bounds.y2 - bounds.y1);
-	    if (!image)
+	    if (!image) {
+		ret = 1;
 		break;
+	    }
 	}
 	FbRasterizeTriangle (image, tris, -bounds.x1, -bounds.y1);
 	if (!format)
 	{
 	    xRel = bounds.x1 + xSrc - xDst;
 	    yRel = bounds.y1 + ySrc - yDst;
-	    pixman_composite (op, src, image, dst,
-			 xRel, yRel, 0, 0, bounds.x1, bounds.y1,
-			 bounds.x2 - bounds.x1, bounds.y2 - bounds.y1);
+	    ret = pixman_composite (op, src, image, dst,
+			            xRel, yRel, 0, 0, bounds.x1, bounds.y1,
+				    bounds.x2 - bounds.x1,
+				    bounds.y2 - bounds.y1);
 	    pixman_image_destroy (image);
+	    if (ret)
+		break;
 	}
 	/* XXX adjust xSrc and ySrc */
     }
@@ -196,16 +202,18 @@ pixman_composite_triangles (pixman_operator_t	op,
     {
 	xRel = bounds.x1 + xSrc - xDst;
 	yRel = bounds.y1 + ySrc - yDst;
-	pixman_composite (op, src, image, dst,
-		     xRel, yRel, 0, 0, bounds.x1, bounds.y1,
-		     bounds.x2 - bounds.x1, bounds.y2 - bounds.y1);
+	ret = pixman_composite (op, src, image, dst,
+		                xRel, yRel, 0, 0, bounds.x1, bounds.y1,
+				bounds.x2 - bounds.x1,
+				bounds.y2 - bounds.y1);
 	pixman_image_destroy (image);
     }
 
     pixman_format_destroy (format);
+    return ret;
 }
 
-void
+int
 pixman_composite_tri_strip (pixman_operator_t		op,
 		     pixman_image_t		*src,
 		     pixman_image_t		*dst,
@@ -220,9 +228,10 @@ pixman_composite_tri_strip (pixman_operator_t		op,
     int		xDst, yDst;
     int		xRel, yRel;
     pixman_format_t	*format;
+    int ret = 0;
 
     if (npoints < 3)
-	return;
+	return 0;
 
     xDst = points[0].x >> 16;
     yDst = points[0].y >> 16;
@@ -233,13 +242,13 @@ pixman_composite_tri_strip (pixman_operator_t		op,
     {
 	pixman_point_fixed_bounds (npoints, points, &bounds);
 	if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1)
-	    return;
+	    return 0;
 	image = FbCreateAlphaPicture (dst,
 				      format,
 				      bounds.x2 - bounds.x1,
 				      bounds.y2 - bounds.y1);
 	if (!image)
-	    return;
+	    return 1;
     }
     for (; npoints >= 3; npoints--, points++)
     {
@@ -255,34 +264,41 @@ pixman_composite_tri_strip (pixman_operator_t		op,
 					  format,
 					  bounds.x2 - bounds.x1,
 					  bounds.y2 - bounds.y1);
-	    if (!image)
-		continue;
+	    if (!image) {
+		ret = 1;
+		break;
+	    }
 	}
 	FbRasterizeTriangle (image, &tri, -bounds.x1, -bounds.y1);
 	if (!format)
 	{
 	    xRel = bounds.x1 + xSrc - xDst;
 	    yRel = bounds.y1 + ySrc - yDst;
-	    pixman_composite (op, src, image, dst,
-			 xRel, yRel, 0, 0, bounds.x1, bounds.y1,
-			 bounds.x2 - bounds.x1, bounds.y2 - bounds.y1);
+	    ret = pixman_composite (op, src, image, dst,
+			            xRel, yRel, 0, 0, bounds.x1, bounds.y1,
+				    bounds.x2 - bounds.x1,
+				    bounds.y2 - bounds.y1);
 	    pixman_image_destroy (image);
+	    if (ret)
+		break;
 	}
     }
     if (format)
     {
 	xRel = bounds.x1 + xSrc - xDst;
 	yRel = bounds.y1 + ySrc - yDst;
-	pixman_composite (op, src, image, dst,
-		     xRel, yRel, 0, 0, bounds.x1, bounds.y1,
-		     bounds.x2 - bounds.x1, bounds.y2 - bounds.y1);
+	ret = pixman_composite (op, src, image, dst,
+		                xRel, yRel, 0, 0, bounds.x1, bounds.y1,
+				bounds.x2 - bounds.x1,
+				bounds.y2 - bounds.y1);
 	pixman_image_destroy (image);
     }
 
     pixman_format_destroy (format);
+    return ret;
 }
 
-void
+int
 pixman_composite_tri_fan (pixman_operator_t		op,
 		   pixman_image_t		*src,
 		   pixman_image_t		*dst,
@@ -298,9 +314,10 @@ pixman_composite_tri_fan (pixman_operator_t		op,
     int		xDst, yDst;
     int		xRel, yRel;
     pixman_format_t	*format;
+    int ret = 0;
 
     if (npoints < 3)
-	return;
+	return 0;
 
     xDst = points[0].x >> 16;
     yDst = points[0].y >> 16;
@@ -311,13 +328,13 @@ pixman_composite_tri_fan (pixman_operator_t		op,
     {
 	pixman_point_fixed_bounds (npoints, points, &bounds);
 	if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1)
-	    return;
+	    return 0;
 	image = FbCreateAlphaPicture (dst,
 				      format,
 				      bounds.x2 - bounds.x1,
 				      bounds.y2 - bounds.y1);
 	if (!image)
-	    return;
+	    return 1;
     }
     first = points++;
     npoints--;
@@ -335,29 +352,36 @@ pixman_composite_tri_fan (pixman_operator_t		op,
 					  format,
 					  bounds.x2 - bounds.x1,
 					  bounds.y2 - bounds.y1);
-	    if (!image)
-		continue;
+	    if (!image) {
+		ret = 1;
+		break;
+	    }
 	}
 	FbRasterizeTriangle (image, &tri, -bounds.x1, -bounds.y1);
 	if (!format)
 	{
 	    xRel = bounds.x1 + xSrc - xDst;
 	    yRel = bounds.y1 + ySrc - yDst;
-	    pixman_composite (op, src, image, dst,
-			 xRel, yRel, 0, 0, bounds.x1, bounds.y1,
-			 bounds.x2 - bounds.x1, bounds.y2 - bounds.y1);
+	    ret = pixman_composite (op, src, image, dst,
+			            xRel, yRel, 0, 0, bounds.x1, bounds.y1,
+			            bounds.x2 - bounds.x1,
+				    bounds.y2 - bounds.y1);
 	    pixman_image_destroy (image);
+	    if (ret)
+		break;
 	}
     }
     if (format)
     {
 	xRel = bounds.x1 + xSrc - xDst;
 	yRel = bounds.y1 + ySrc - yDst;
-	pixman_composite (op, src, image, dst,
-		     xRel, yRel, 0, 0, bounds.x1, bounds.y1,
-		     bounds.x2 - bounds.x1, bounds.y2 - bounds.y1);
+	ret = pixman_composite (op, src, image, dst,
+		                xRel, yRel, 0, 0, bounds.x1, bounds.y1,
+		                bounds.x2 - bounds.x1,
+			       	bounds.y2 - bounds.y1);
 	pixman_image_destroy (image);
     }
 
     pixman_format_destroy (format);
+    return ret;
 }
diff --git a/pixman/src/pixman.h b/pixman/src/pixman.h
index acf5327..a4241c4 100644
--- a/pixman/src/pixman.h
+++ b/pixman/src/pixman.h
@@ -442,7 +442,7 @@ pixman_pixel_to_color (const pixman_format_t	*format,
 
 /* icrect.c */
 
-pixman_private void
+pixman_private int
 pixman_fill_rectangle (pixman_operator_t	op,
 		       pixman_image_t		*dst,
 		       const pixman_color_t	*color,
@@ -451,7 +451,7 @@ pixman_fill_rectangle (pixman_operator_t	op,
 		       unsigned int		width,
 		       unsigned int		height);
 
-pixman_private void
+pixman_private int
 pixman_fill_rectangles (pixman_operator_t		op,
 			pixman_image_t			*dst,
 			const pixman_color_t		*color,
@@ -460,7 +460,7 @@ pixman_fill_rectangles (pixman_operator_t		op,
 
 /* ictrap.c */
 
-pixman_private void
+pixman_private int
 pixman_composite_trapezoids (pixman_operator_t		op,
 			     pixman_image_t		*src,
 			     pixman_image_t		*dst,
@@ -478,7 +478,7 @@ pixman_add_trapezoids (pixman_image_t		*dst,
 
 /* ictri.c */
 
-pixman_private void
+pixman_private int
 pixman_composite_triangles (pixman_operator_t		op,
 			    pixman_image_t		*src,
 			    pixman_image_t		*dst,
@@ -487,7 +487,7 @@ pixman_composite_triangles (pixman_operator_t		op,
 			    const pixman_triangle_t	*tris,
 			    int				ntris);
 
-pixman_private void
+pixman_private int
 pixman_composite_tri_strip (pixman_operator_t		op,
 			    pixman_image_t		*src,
 			    pixman_image_t		*dst,
@@ -496,7 +496,7 @@ pixman_composite_tri_strip (pixman_operator_t		op,
 			    const pixman_point_fixed_t	*points,
 			    int				npoints);
 
-pixman_private void
+pixman_private int
 pixman_composite_tri_fan (pixman_operator_t		op,
 			  pixman_image_t		*src,
 			  pixman_image_t		*dst,
@@ -507,7 +507,7 @@ pixman_composite_tri_fan (pixman_operator_t		op,
 
 /* ic.c */
 
-pixman_private void
+pixman_private int
 pixman_composite (pixman_operator_t	op,
 		  pixman_image_t	*iSrc,
 		  pixman_image_t	*iMask,
-- 
1.4.4.2



More information about the cairo mailing list