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

This commit is contained in:
Dmitry Timoshkov 2007-12-20 14:49:59 +08:00 committed by Alexandre Julliard
parent 18407eafdc
commit c3fe9ec2f7
2 changed files with 18 additions and 0 deletions

View File

@ -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);

View File

@ -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)