gdi32/tests: Zero initialize DEVMODE before passing it to EnumDisplaySettings().

Zero initialize DEVMODE before passing it to EnumDisplaySettings(), which may write beyond the end
of the DEVMODE structure on Windows because the dmDriverExtra field is uninitialized.

Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zhiyi Zhang 2020-08-11 18:15:19 +08:00 committed by Alexandre Julliard
parent c3bd08b022
commit ee1880a756
1 changed files with 4 additions and 0 deletions

View File

@ -242,6 +242,8 @@ static void test_GdiConvertToDevmodeW(void)
return;
}
memset(&dmA, 0, sizeof(dmA));
dmA.dmSize = sizeof(dmA);
ret = EnumDisplaySettingsA(NULL, ENUM_CURRENT_SETTINGS, &dmA);
ok(ret, "EnumDisplaySettingsExA error %u\n", GetLastError());
ok(dmA.dmSize >= FIELD_OFFSET(DEVMODEA, dmICMMethod), "dmSize is too small: %04x\n", dmA.dmSize);
@ -591,6 +593,8 @@ static void test_CreateCompatibleDC(void)
bitmap = CreateBitmap( 10, 10, 1, 1, NULL );
memset(&dm, 0, sizeof(dm));
dm.dmSize = sizeof(dm);
bRet = EnumDisplaySettingsA(NULL, ENUM_CURRENT_SETTINGS, &dm);
ok(bRet, "EnumDisplaySettingsEx failed\n");
dm.u1.s1.dmScale = 200;