[PATCH] [render] Explicitly check width/height == 0 in ProcRenderCreateCursor()

Tomas Carnecky tom at dbservice.com
Sun Dec 6 14:52:56 PST 2009


Previously the code would rely on xalloc(0) to return NULL and so in case
either width or height is zero return an error to the client. It's better
to be explicit though so add a check and return BadAlloc in that case.

Signed-off-by: Tomas Carnecky <tom at dbservice.com>
---
 render/render.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/render/render.c b/render/render.c
index 45856a7..041a2d7 100644
--- a/render/render.c
+++ b/render/render.c
@@ -1531,7 +1531,9 @@ ProcRenderCreateCursor (ClientPtr client)
     pScreen = pSrc->pDrawable->pScreen;
     width = pSrc->pDrawable->width;
     height = pSrc->pDrawable->height;
-    if (height && width > UINT32_MAX/(height*sizeof(CARD32)))
+    if (width == 0 || height == 0)
+	    return (BadAlloc);
+    if (width > UINT32_MAX/(height*sizeof(CARD32)))
 	return BadAlloc;
     if ( stuff->x > width 
       || stuff->y > height )
-- 
1.6.5.4




More information about the xorg-devel mailing list