From 332d62ba108ff5d33ae1007f16eb3e2a94efd839 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 31 May 2002 19:14:40 +0000 Subject: [PATCH] Avoid division by zero (thanks to David Ronis). --- dlls/x11drv/mouse.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/dlls/x11drv/mouse.c b/dlls/x11drv/mouse.c index b4db4b2dff9..76d6dfd6a95 100644 --- a/dlls/x11drv/mouse.c +++ b/dlls/x11drv/mouse.c @@ -301,13 +301,21 @@ Cursor X11DRV_GetCursor( Display *display, CURSORICONINFO *ptr ) rscale = 1 << (16 - rbits); gscale = 1 << (16 - gbits); bscale = 1 << (16 - bbits); - fg.red = rfg * rscale / fgBits; - fg.green = gfg * gscale / fgBits; - fg.blue = bfg * bscale / fgBits; + if (fgBits) + { + fg.red = rfg * rscale / fgBits; + fg.green = gfg * gscale / fgBits; + fg.blue = bfg * bscale / fgBits; + } + else fg.red = fg.green = fg.blue = 0; bgBits = xmax * ymax - fgBits; - bg.red = rbg * rscale / bgBits; - bg.green = gbg * gscale / bgBits; - bg.blue = bbg * bscale / bgBits; + if (bgBits) + { + bg.red = rbg * rscale / bgBits; + bg.green = gbg * gscale / bgBits; + bg.blue = bbg * bscale / bgBits; + } + else bg.red = bg.green = bg.blue = 0; pixmapBits = XCreateBitmapFromData( display, root_window, pXorBits, xmax, ymax ); if (!pixmapBits) {