Author: jgardou
Date: Fri Mar 11 10:33:03 2011
New Revision: 51014
URL:
http://svn.reactos.org/svn/reactos?rev=51014&view=rev
Log:
[GDI32]
- allocate sufficient buffer when creating a DIBSECTION compatible bitmap.
Fixes bug 5822
Modified:
trunk/reactos/dll/win32/gdi32/objects/bitmap.c
Modified: trunk/reactos/dll/win32/gdi32/objects/bitmap.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/objects/bi…
==============================================================================
--- trunk/reactos/dll/win32/gdi32/objects/bitmap.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/gdi32/objects/bitmap.c [iso-8859-1] Fri Mar 11 10:33:03 2011
@@ -348,8 +348,6 @@
INT Height)
{
PDC_ATTR pDc_Attr;
- HBITMAP hBmp = NULL;
- DIBSECTION dibs;
if (!GdiGetHandleUserData(hDC, GDI_OBJECT_TYPE_DC, (PVOID)&pDc_Attr))
return NULL;
@@ -361,19 +359,26 @@
{
return NtGdiCreateCompatibleBitmap(hDC, Width, Height);
}
-
- hBmp = NtGdiGetDCObject(hDC, GDI_OBJECT_TYPE_BITMAP);
-
- if ( GetObjectA(hBmp, sizeof(DIBSECTION), &dibs) != sizeof(DIBSECTION) )
- return NULL;
-
- if ( dibs.dsBm.bmBitsPixel <= 8 )
- GetDIBColorTable(hDC, 0, 256, (RGBQUAD *)&dibs.dsBitfields);
-
- dibs.dsBmih.biWidth = Width;
- dibs.dsBmih.biHeight = Height;
-
- return CreateDIBSection(hDC, (CONST BITMAPINFO *)&dibs.dsBmih, 0, NULL, NULL,
0);
+ else
+ {
+ HBITMAP hBmp = NULL;
+ char buffer[sizeof(DIBSECTION) + 256*sizeof(RGBQUAD)];
+ DIBSECTION* pDIBs = (DIBSECTION*)buffer;
+
+ hBmp = NtGdiGetDCObject(hDC, GDI_OBJECT_TYPE_BITMAP);
+
+ if ( GetObjectA(hBmp, sizeof(DIBSECTION), pDIBs) != sizeof(DIBSECTION) )
+ return NULL;
+
+ if ( pDIBs->dsBm.bmBitsPixel <= 8 )
+ GetDIBColorTable(hDC, 0, 256, (RGBQUAD *)&pDIBs->dsBitfields[0]);
+
+ pDIBs->dsBmih.biWidth = Width;
+ pDIBs->dsBmih.biHeight = Height;
+
+ return CreateDIBSection(hDC, (CONST BITMAPINFO *)&pDIBs->dsBmih, 0, NULL,
NULL, 0);
+ }
+ return NULL;
}