Commit 9301a9e1 authored by Jinoh Kang's avatar Jinoh Kang Committed by Alexandre Julliard

gdi32: Calculate effective number of scan lines and truncate bitmap bits for EMR_SETDIBITSTODEVICE.

parent da126e19
...@@ -1815,6 +1815,7 @@ BOOL EMFDC_SetDIBitsToDevice( DC_ATTR *dc_attr, INT x_dst, INT y_dst, DWORD widt ...@@ -1815,6 +1815,7 @@ BOOL EMFDC_SetDIBitsToDevice( DC_ATTR *dc_attr, INT x_dst, INT y_dst, DWORD widt
EMRSETDIBITSTODEVICE *emr; EMRSETDIBITSTODEVICE *emr;
BOOL ret; BOOL ret;
UINT bmi_size, img_size, payload_size, emr_size; UINT bmi_size, img_size, payload_size, emr_size;
UINT src_height, stride;
BITMAPINFOHEADER bih; BITMAPINFOHEADER bih;
BITMAPINFO *bi; BITMAPINFO *bi;
...@@ -1822,6 +1823,25 @@ BOOL EMFDC_SetDIBitsToDevice( DC_ATTR *dc_attr, INT x_dst, INT y_dst, DWORD widt ...@@ -1822,6 +1823,25 @@ BOOL EMFDC_SetDIBitsToDevice( DC_ATTR *dc_attr, INT x_dst, INT y_dst, DWORD widt
if (!emf_parse_user_bitmapinfo( &bih, &info->bmiHeader, usage, TRUE, if (!emf_parse_user_bitmapinfo( &bih, &info->bmiHeader, usage, TRUE,
&bmi_size, &img_size )) return 0; &bmi_size, &img_size )) return 0;
if (bih.biHeight >= 0)
{
src_height = (UINT)bih.biHeight;
if (src_height > y_src + height) src_height = y_src + height;
if (src_height < startscan) lines = 0;
else if (lines > src_height - startscan) lines = src_height - startscan;
if (!lines) return 0;
if (bih.biCompression == BI_RGB || bih.biCompression == BI_BITFIELDS)
{
/* truncate image and check for overflows */
stride = get_dib_stride( bih.biWidth, bih.biBitCount );
img_size = lines * stride;
if (img_size / stride != lines) return 0;
}
}
/* check for overflows */ /* check for overflows */
payload_size = bmi_size + img_size; payload_size = bmi_size + img_size;
if (payload_size < bmi_size) return 0; if (payload_size < bmi_size) return 0;
......
...@@ -7764,13 +7764,6 @@ static void test_emf_SetDIBitsToDevice(void) ...@@ -7764,13 +7764,6 @@ static void test_emf_SetDIBitsToDevice(void)
{ {
winetest_push_context("Test %d", test_idx); winetest_push_context("Test %d", test_idx);
if (tests[test_idx].height != bitmap_height && !strcmp(winetest_platform, "wine"))
{
skip("Wine does not adjust cLines appropriately\n");
winetest_pop_context();
continue;
}
memset(&bmi, 0, sizeof(bmi)); memset(&bmi, 0, sizeof(bmi));
if (tests[test_idx].infomode < 2) if (tests[test_idx].infomode < 2)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment