Alexandre Julliard : gdi32: Add a check for null bitfields in SetDIBits.
Alexandre Julliard
julliard at winehq.org
Thu Oct 13 14:10:10 CDT 2011
Module: wine
Branch: master
Commit: 34310d44792b334d4995b1830c4137d9b764eba8
URL: http://source.winehq.org/git/wine.git/?a=commit;h=34310d44792b334d4995b1830c4137d9b764eba8
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Oct 13 00:43:05 2011 +0200
gdi32: Add a check for null bitfields in SetDIBits.
---
dlls/gdi32/dib.c | 9 +++++++++
dlls/gdi32/tests/bitmap.c | 6 +++---
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/dlls/gdi32/dib.c b/dlls/gdi32/dib.c
index 56efda7..20041ad 100644
--- a/dlls/gdi32/dib.c
+++ b/dlls/gdi32/dib.c
@@ -519,6 +519,15 @@ INT WINAPI SetDIBits( HDC hdc, HBITMAP hbitmap, UINT startscan,
SetLastError( ERROR_INVALID_PARAMETER );
return 0;
}
+ if (src_info->bmiHeader.biCompression == BI_BITFIELDS)
+ {
+ DWORD *masks = (DWORD *)src_info->bmiColors;
+ if (!masks[0] || !masks[1] || !masks[2])
+ {
+ SetLastError( ERROR_INVALID_PARAMETER );
+ return 0;
+ }
+ }
src_bits.ptr = (void *)bits;
src_bits.is_copy = FALSE;
diff --git a/dlls/gdi32/tests/bitmap.c b/dlls/gdi32/tests/bitmap.c
index eaf96a5..e069fa8 100644
--- a/dlls/gdi32/tests/bitmap.c
+++ b/dlls/gdi32/tests/bitmap.c
@@ -976,7 +976,7 @@ static void test_dib_formats(void)
hdib = CreateDIBSection(hdc, bi, DIB_RGB_COLORS, &bits, NULL, 0);
ok( hdib == NULL, "CreateDIBSection succeeded with null bitfields\n" );
ret = SetDIBits(hdc, hbmp, 0, 1, data, bi, DIB_RGB_COLORS);
- todo_wine ok( !ret, "SetDIBits succeeded with null bitfields\n" );
+ ok( !ret, "SetDIBits succeeded with null bitfields\n" );
/* other functions don't check */
hdib = CreateDIBitmap( hdc, &bi->bmiHeader, 0, bits, bi, DIB_RGB_COLORS );
ok( hdib != NULL, "CreateDIBitmap failed with null bitfields\n" );
@@ -984,7 +984,7 @@ static void test_dib_formats(void)
ret = SetDIBitsToDevice( memdc, 0, 0, 1, 1, 0, 0, 0, 1, data, bi, DIB_RGB_COLORS );
ok( ret, "SetDIBitsToDevice failed with null bitfields\n" );
ret = StretchDIBits( memdc, 0, 0, 1, 1, 0, 0, 1, 1, data, bi, DIB_RGB_COLORS, SRCCOPY );
- ok( ret, "StretchDIBits failed with null bitfields\n" );
+ todo_wine ok( ret, "StretchDIBits failed with null bitfields\n" );
ret = GetDIBits(hdc, hbmp, 0, 2, data, bi, DIB_RGB_COLORS);
ok( ret, "GetDIBits failed with null bitfields\n" );
bi->bmiHeader.biPlanes = 1;
@@ -1004,7 +1004,7 @@ static void test_dib_formats(void)
hdib = CreateDIBSection(hdc, bi, DIB_RGB_COLORS, &bits, NULL, 0);
ok( hdib == NULL, "CreateDIBSection succeeded with null bitfields\n" );
ret = SetDIBits(hdc, hbmp, 0, 1, data, bi, DIB_RGB_COLORS);
- todo_wine ok( !ret, "SetDIBits succeeded with null bitfields\n" );
+ ok( !ret, "SetDIBits succeeded with null bitfields\n" );
/* garbage is ok though */
*(DWORD *)&bi->bmiColors[0] = 0x55;
More information about the wine-cvs
mailing list