user32: Fix a memory leak on a error patch (Smatch).

Michael Stefaniuc mstefani at redhat.de
Mon Oct 5 17:53:24 CDT 2009


The code allocates both buffers before checking for memory allocation
errors. Thus in case one allocation succeeds and the other fails there
will be a memory leak. Fixed by unconditionally freeing the buffers
at the end of their lifetime.

Signed-off-by: Michael Stefaniuc <mstefani at redhat.de>
---
 dlls/user32/cursoricon.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c
index fca04ce..2ed1138 100644
--- a/dlls/user32/cursoricon.c
+++ b/dlls/user32/cursoricon.c
@@ -828,10 +828,10 @@ static HICON CURSORICON_CreateIconFromBMI( BITMAPINFO *bmi,
                     hXorBits = 0;
                 }
             }
-
-            HeapFree( GetProcessHeap(), 0, pSrcInfo );
-            HeapFree( GetProcessHeap(), 0, pDestInfo );
         }
+
+        HeapFree( GetProcessHeap(), 0, pSrcInfo );
+        HeapFree( GetProcessHeap(), 0, pDestInfo );
     }
 
     if( !hXorBits || !hAndBits )
-- 
1.6.5.rc2



More information about the wine-patches mailing list