Module: wine Branch: master Commit: 4e527045d59238ceb57110415470fb6213313043 URL: https://gitlab.winehq.org/wine/wine/-/commit/4e527045d59238ceb57110415470fb6...
Author: Piotr Caban piotr@codeweavers.com Date: Mon Nov 21 11:50:24 2022 +0100
gdi32: Don't crash in StartDoc on NULL DOCINFO.
---
dlls/gdi32/dc.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c index cece9625739..0cdeff19e05 100644 --- a/dlls/gdi32/dc.c +++ b/dlls/gdi32/dc.c @@ -2155,16 +2155,29 @@ INT WINAPI StartDocW( HDC hdc, const DOCINFOW *doc ) { DC_ATTR *dc_attr; ABORTPROC proc; + DOCINFOW info; + + TRACE("%p %p\n", hdc, doc); + + if (doc) + { + info = *doc; + } + else + { + memset( &info, 0, sizeof(info) ); + info.cbSize = sizeof(info); + }
TRACE("DocName %s, Output %s, Datatype %s, fwType %#lx\n", - debugstr_w(doc->lpszDocName), debugstr_w(doc->lpszOutput), - debugstr_w(doc->lpszDatatype), doc->fwType); + debugstr_w(info.lpszDocName), debugstr_w(info.lpszOutput), + debugstr_w(info.lpszDatatype), info.fwType);
if (!(dc_attr = get_dc_attr( hdc ))) return SP_ERROR;
proc = (ABORTPROC)(UINT_PTR)dc_attr->abort_proc; if (proc && !proc( hdc, 0 )) return 0; - return NtGdiStartDoc( hdc, doc, NULL, 0 ); + return NtGdiStartDoc( hdc, &info, NULL, 0 ); }
/*********************************************************************** @@ -2176,6 +2189,8 @@ INT WINAPI StartDocA( HDC hdc, const DOCINFOA *doc ) DOCINFOW docW; INT ret, len;
+ if (!doc) return StartDocW(hdc, NULL); + docW.cbSize = doc->cbSize; if (doc->lpszDocName) {