Alexandre Julliard : gdi32: Create a sanitized BITMAPINFOHEADER in CreateDIBitmap.

Alexandre Julliard julliard at winehq.org
Thu Aug 4 12:22:11 CDT 2011


Module: wine
Branch: master
Commit: 3d0f272a0de152f636da12f96550f753dc263bc8
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=3d0f272a0de152f636da12f96550f753dc263bc8

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Aug  4 12:52:23 2011 +0200

gdi32: Create a sanitized BITMAPINFOHEADER in CreateDIBitmap.

---

 dlls/gdi32/dib.c |   26 +++++++++-----------------
 1 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/dlls/gdi32/dib.c b/dlls/gdi32/dib.c
index eebe3dd..d53289b 100644
--- a/dlls/gdi32/dib.c
+++ b/dlls/gdi32/dib.c
@@ -1159,32 +1159,24 @@ HBITMAP WINAPI CreateDIBitmap( HDC hdc, const BITMAPINFOHEADER *header,
                             DWORD init, LPCVOID bits, const BITMAPINFO *data,
                             UINT coloruse )
 {
+    BITMAPINFOHEADER info;
     HBITMAP handle;
-    LONG width;
     LONG height;
-    WORD planes, bpp;
-    DWORD compr, size;
 
-    if (!header) return 0;
+    if (!bitmapinfoheader_from_user_bitmapinfo( &info, header )) return 0;
+    if (info.biWidth < 0) return 0;
 
-    if (DIB_GetBitmapInfo( header, &width, &height, &planes, &bpp, &compr, &size ) == -1) return 0;
-    
-    if (width < 0)
-    {
-        TRACE("Bitmap has a negative width\n");
-        return 0;
-    }
-    
     /* Top-down DIBs have a negative height */
-    if (height < 0) height = -height;
+    height = abs( info.biHeight );
 
     TRACE("hdc=%p, header=%p, init=%u, bits=%p, data=%p, coloruse=%u (bitmap: width=%d, height=%d, bpp=%u, compr=%u)\n",
-           hdc, header, init, bits, data, coloruse, width, height, bpp, compr);
-    
+          hdc, header, init, bits, data, coloruse, info.biWidth, info.biHeight,
+          info.biBitCount, info.biCompression);
+
     if (hdc == NULL)
-        handle = CreateBitmap( width, height, 1, 1, NULL );
+        handle = CreateBitmap( info.biWidth, height, 1, 1, NULL );
     else
-        handle = CreateCompatibleBitmap( hdc, width, height );
+        handle = CreateCompatibleBitmap( hdc, info.biWidth, height );
 
     if (handle)
     {




More information about the wine-cvs mailing list