[ros-diffs] [tkreuzer] 32247: fix a mem leak in win32k bitmap code

tkreuzer at svn.reactos.org tkreuzer at svn.reactos.org
Sun Feb 10 03:33:12 CET 2008


Author: tkreuzer
Date: Sun Feb 10 05:33:11 2008
New Revision: 32247

URL: http://svn.reactos.org/svn/reactos?rev=32247&view=rev
Log:
fix a mem leak in win32k bitmap code

Modified:
    trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c
    trunk/reactos/subsystems/win32/win32k/objects/dibobj.c

Modified: trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c?rev=32247&r1=32246&r2=32247&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c Sun Feb 10 05:33:11 2008
@@ -70,22 +70,21 @@
       return 0;
    }
 
+   PBITMAPOBJ bmp = BITMAPOBJ_LockBitmap( hBitmap );
+   if (bmp == NULL)
+   {
+      NtGdiDeleteObject(hBitmap);
+      return NULL;
+   }
+
+   bmp->flFlags = BITMAPOBJ_IS_APIBITMAP;
+
    if (NULL != pBits)
    {
-       PBITMAPOBJ bmp = BITMAPOBJ_LockBitmap( hBitmap );
-       if (bmp == NULL)
-       {
-          NtGdiDeleteObject(hBitmap);
-          return NULL;
-       }
-
-       bmp->flFlags = BITMAPOBJ_IS_APIBITMAP;
-
        IntSetBitmapBits(bmp, bmp->SurfObj.cjBits, pBits);
-
-
-       BITMAPOBJ_UnlockBitmap( bmp );
    }
+
+   BITMAPOBJ_UnlockBitmap( bmp );
 
    DPRINT("IntGdiCreateBitmap : %dx%d, %d BPP colors, topdown %d, returning %08x\n",
           Size.cx, Size.cy, BitsPixel, (Height < 0 ? 1 : 0), hBitmap);

Modified: trunk/reactos/subsystems/win32/win32k/objects/dibobj.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/dibobj.c?rev=32247&r1=32246&r2=32247&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/dibobj.c (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/dibobj.c Sun Feb 10 05:33:11 2008
@@ -809,11 +809,8 @@
   LONG compr;
   LONG dibsize;
   BOOL fColor;
-  SIZEL size;
-
 
   if (DIB_GetBitmapInfo( header, &width, &height, &planes, &bpp, &compr, &dibsize ) == -1) return 0;
-
 
   // Check if we should create a monochrome or color bitmap. We create a monochrome bitmap only if it has exactly 2
   // colors, which are black followed by white, nothing else. In all other cases, we create a color bitmap.
@@ -866,12 +863,11 @@
   }
   else
   {
-    size.cx = width;
-    size.cy = abs(height);
-
-    handle = IntCreateBitmap(size, DIB_GetDIBWidthBytes(width, 1), BMF_1BPP,
-                             (height < 0 ? BMF_TOPDOWN : 0) | BMF_NOZEROINIT,
-                             NULL);
+    handle = IntGdiCreateBitmap(width,
+                                height,
+                                1,
+                                1,
+                                NULL);
   }
 
   if (height < 0)




More information about the Ros-diffs mailing list