Commit c3fe9ec2 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

gdi32: Add a test for minimal acceptable DEVMODEA size, make it pass under Wine.

parent 18407eaf
......@@ -414,6 +414,11 @@ DEVMODEW * WINAPI GdiConvertToDevmodeW(const DEVMODEA *dmA)
WORD dmW_size, dmA_size;
dmA_size = dmA->dmSize;
/* this is the minimal dmSize that XP accepts */
if (dmA_size < FIELD_OFFSET(DEVMODEA, dmFields))
return NULL;
if (dmA_size > sizeof(DEVMODEA))
dmA_size = sizeof(DEVMODEA);
......
......@@ -222,6 +222,19 @@ static void test_GdiConvertToDevmodeW(void)
"expected %04x, got %04x\n",
FIELD_OFFSET(DEVMODEW, dmPanningHeight) + sizeof(dmW->dmPanningHeight), dmW->dmSize);
HeapFree(GetProcessHeap(), 0, dmW);
SetLastError(0xdeadbeef);
dmA.dmSize = 0;
dmW = pGdiConvertToDevmodeW(&dmA);
ok(!dmW, "GdiConvertToDevmodeW should fail\n");
ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", GetLastError());
/* this is the minimal dmSize that XP accepts */
dmA.dmSize = FIELD_OFFSET(DEVMODEA, dmFields);
dmW = pGdiConvertToDevmodeW(&dmA);
ok(dmW->dmSize == FIELD_OFFSET(DEVMODEW, dmFields),
"expected %04x, got %04x\n", FIELD_OFFSET(DEVMODEW, dmFields), dmW->dmSize);
HeapFree(GetProcessHeap(), 0, dmW);
}
START_TEST(dc)
......
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