winex11.drv: Initialize a variable in create_xcursor_frame to cover corner cases.

Gerald Pfeifer gerald at pfeifer.com
Sun Apr 3 14:23:38 CDT 2011


The code in question is the following:

    /* check if the cursor frame was drawn with an alpha channel */
    for (i = 0, ptr = image->pixels; i < width * height; i++, ptr++)
        if ((has_alpha = (*ptr & 0xff000000) != 0)) break;
    
    /* if no alpha channel was drawn then generate it from the mask */
    if (!has_alpha)

If either width or height is 0, or negative (both are of int type)
indeed the loop does not execute once and has_alpha remains unset.

This addresses it, and a compiler warning issued by GCC 4.6.0.

Gerald

---
 dlls/winex11.drv/mouse.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
index ab500ef..1a2d618 100644
--- a/dlls/winex11.drv/mouse.c
+++ b/dlls/winex11.drv/mouse.c
@@ -295,7 +295,7 @@ static XcursorImage *create_xcursor_frame( HDC hdc, const ICONINFOEXW *iinfo, HA
 {
     XcursorImage *image, *ret = NULL;
     DWORD delay_jiffies, num_steps;
-    int x, y, i, has_alpha;
+    int x, y, i, has_alpha = FALSE;
     XcursorPixel *ptr;
 
     wine_tsx11_lock();
-- 
1.7.4.1



More information about the wine-patches mailing list