From 6762313cdf2be18a6e5bf69ec7c302425488f7bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20Belleng=C3=A9?= Date: Mon, 25 Apr 2005 16:02:27 +0000 Subject: [PATCH] Prevent CreateDCA from crashing if a bad lpInitData parameter is provided. --- dlls/gdi/dc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/dlls/gdi/dc.c b/dlls/gdi/dc.c index 1d6f6d3f094..3cddbe80fdd 100644 --- a/dlls/gdi/dc.c +++ b/dlls/gdi/dc.c @@ -38,6 +38,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(dc); +static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 }; + static BOOL DC_DeleteObject( HGDIOBJ handle, void *obj ); static const struct gdi_obj_funcs dc_funcs = @@ -670,8 +672,13 @@ HDC WINAPI CreateDCA( LPCSTR driver, LPCSTR device, LPCSTR output, if (output) RtlCreateUnicodeStringFromAsciiz(&outputW, output); else outputW.Buffer = NULL; - if (initData) initDataW = GdiConvertToDevmodeW(initData); - else initDataW = NULL; + initDataW = NULL; + if (initData) + { + /* don't convert initData for DISPLAY driver, it's not used */ + if (!driverW.Buffer || strcmpiW( driverW.Buffer, displayW )) + initDataW = GdiConvertToDevmodeW(initData); + } ret = CreateDCW( driverW.Buffer, deviceW.Buffer, outputW.Buffer, initDataW ); @@ -725,7 +732,6 @@ HDC WINAPI CreateCompatibleDC( HDC hdc ) } else { - static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 }; funcs = DRIVER_load_driver( displayW ); physDev = NULL; }