[PATCH] render: set the glyph picture to NULL by default.

Peter Hutterer peter.hutterer at who-t.net
Wed Sep 30 17:01:37 PDT 2009


In a follow-up patch we may have glyphs with a NULL picture. To cope with
that, always set the pictures for glyphs to NULL at creation time and cope
with cleaning up such glyphs. Also, since compositing a NULL source doesn't
do a lot anyway, return early when trying to do so.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 render/glyph.c   |    4 +++-
 render/picture.c |    5 ++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/render/glyph.c b/render/glyph.c
index 6327c9f..55e1827 100644
--- a/render/glyph.c
+++ b/render/glyph.c
@@ -282,7 +282,8 @@ FreeGlyphPicture(GlyphPtr glyph)
     {
         ScreenPtr pScreen = screenInfo.screens[i];
 
-        FreePicture ((pointer) GlyphPicture (glyph)[i], 0);
+        if (GlyphPicture(glyph)[i])
+            FreePicture ((pointer) GlyphPicture (glyph)[i], 0);
 
         ps = GetPictureScreenIfSet (pScreen);
         if (ps)
@@ -414,6 +415,7 @@ AllocateGlyph (xGlyphInfo *gi, int fdepth)
 
     for (i = 0; i < screenInfo.numScreens; i++)
     {
+	GlyphPicture(glyph)[i] = NULL;
 	ps = GetPictureScreenIfSet (screenInfo.screens[i]);
 
 	if (ps)
diff --git a/render/picture.c b/render/picture.c
index e1a2972..ed8f94f 100644
--- a/render/picture.c
+++ b/render/picture.c
@@ -1705,7 +1705,10 @@ CompositePicture (CARD8		op,
 		  CARD16	height)
 {
     PictureScreenPtr	ps = GetPictureScreen(pDst->pDrawable->pScreen);
-    
+
+    if (!pSrc)
+	return;
+
     ValidatePicture (pSrc);
     if (pMask)
 	ValidatePicture (pMask);
-- 
1.6.3.rc1.2.g0164.dirty


--VS++wcV0S1rZb1Fb
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="0001-render-Fix-crash-in-RenderAddGlyphs-23645.patch"



More information about the xorg-devel mailing list