gdi32: Prevent integer overflow in CreateBitmapIndirect.
authorLei Zhang <thestig@google.com>
Wed, 17 Dec 2008 02:24:29 +0000 (18:24 -0800)
committerAlexandre Julliard <julliard@winehq.org>
Wed, 17 Dec 2008 12:52:41 +0000 (13:52 +0100)
dlls/gdi32/bitmap.c

index e7370a246503bd67bd98960026557379441e85fb..2a083c5059164824112ea2be1c7d690caeb9b342 100644 (file)
@@ -274,7 +274,7 @@ HBITMAP WINAPI CreateBitmapIndirect( const BITMAP *bmp )
     /* Windows ignores the provided bm.bmWidthBytes */
     bm.bmWidthBytes = BITMAP_GetWidthBytes( bm.bmWidth, bm.bmBitsPixel );
     /* XP doesn't allow to create bitmaps larger than 128 Mb */
-    if (bm.bmHeight * bm.bmWidthBytes > 128 * 1024 * 1024)
+    if (bm.bmHeight > 128 * 1024 * 1024 / bm.bmWidthBytes)
     {
         SetLastError( ERROR_NOT_ENOUGH_MEMORY );
         return 0;