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 --- dlls/gdi32/tests/dc.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/dlls/gdi32/tests/dc.c b/dlls/gdi32/tests/dc.c index 6640134d1fa..b4a89b213d2 100644 --- a/dlls/gdi32/tests/dc.c +++ b/dlls/gdi32/tests/dc.c @@ -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;