winex11.drv: fix memory leak in create_cursor (found by Smatch)

Lionel_Debroux lionel_debroux at yahoo.fr
Fri Aug 31 02:14:53 CDT 2007


create_cursor leaks some heap memory in an error path. Found in
Michael Stefaniuc's list of Wine potential bugs detected by Smatch.

I'm almost sure that the other potential memory leak detected by Smatch,
in the same function, is NOTABUG. Indeed, bitMask32 is conditionally
freed at line 850, if the number of bits per pixel (ptr->bBitsPerPixel)
is 32 - which is the condition which led to bitMask32 being allocated,
at line 639.

2007-08-31  Lionel Debroux <lionel_debroux at yahoo.fr>
       * dlls/winex11.drv/mouse.c:
       winex11.drv: Fix memory leak in create_cursor (found by Smatch)
-------------- next part --------------
>From d62a874a6d399546940a97fc3d800a692c08b362 Mon Sep 17 00:00:00 2001
From: Lionel Debroux <lionel_debroux at yahoo.fr>
Date: Fri, 31 Aug 2007 08:16:36 +0200
Subject: winex11.drv: fix memory leak in create_cursor (found by Smatch).

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

diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
index 86dad89..d8bf30a 100644
--- a/dlls/winex11.drv/mouse.c
+++ b/dlls/winex11.drv/mouse.c
@@ -763,6 +763,8 @@ static Cursor create_cursor( Display *display, CURSORICONINFO *ptr )
             pixmapBits = XCreateBitmapFromData( display, root_window, (char *)pXorBits, xmax, ymax );
             if (!pixmapBits)
             {
+                if (bitMask32)
+                    HeapFree( GetProcessHeap(), 0, bitMask32 );
                 XFreePixmap( display, pixmapAll );
                 XFreeGC( display, gc );
                 image->data = NULL;
-- 
1.4.4.4



More information about the wine-patches mailing list