[PATCH 05/14] miPolyPoint bugfix: Check memory allocation before changing the GC.

Jamey Sharp jamey at minilop.net
Sat May 8 16:39:20 PDT 2010


miPolyPoint ought to leave the GC unchanged even if it fails. Probably
nobody has ever seen it fail--this bug has been in X.org since at least
the beginning of git history--but might as well fix it.

Signed-off-by: Jamey Sharp <jamey at minilop.net>
---
 mi/mipolypnt.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/mi/mipolypnt.c b/mi/mipolypnt.c
index 5d6243a..12771ee 100644
--- a/mi/mipolypnt.c
+++ b/mi/mipolypnt.c
@@ -73,6 +73,9 @@ miPolyPoint(
     int			i;
     xPoint 		*ppt;
 
+    if(!(pwidthInit = xalloc(npt * sizeof(int))))
+	return;
+
     /* make pointlist origin relative */
     if (mode == CoordModePrevious)
     {
@@ -107,8 +110,6 @@ miPolyPoint(
 	DoChangeGC(pGC, GCFillStyle, &fsNew, 0);
 	ValidateGC(pDrawable, pGC);
     }
-    if(!(pwidthInit = xalloc(npt * sizeof(int))))
-	return;
     pwidth = pwidthInit;
     for(i = 0; i < npt; i++)
 	*pwidth++ = 1;
-- 
1.7.0



More information about the xorg-devel mailing list