diff --git a/reactos/subsys/win32k/objects/dc.c b/reactos/subsys/win32k/objects/dc.c index 5a331353c7e..a92752fc78b 100644 --- a/reactos/subsys/win32k/objects/dc.c +++ b/reactos/subsys/win32k/objects/dc.c @@ -2069,8 +2069,17 @@ NtGdiSelectObject(HDC hDC, HGDIOBJ hGDIObj) HRGN hVisRgn; BOOLEAN Failed; - if(!hDC || !hGDIObj) return NULL; - + if (!hDC || !hGDIObj) + { + /* From Wine: + * SelectObject() with a NULL DC returns 0 and sets ERROR_INVALID_HANDLE. + * Note: Under XP at least invalid ptrs can also be passed, not just NULL; + * Don't test that here in case it crashes earlier win versions. + */ + if (!hDC) SetLastWin32Error(ERROR_INVALID_HANDLE); + return NULL; + } + dc = DC_LockDc(hDC); if (NULL == dc) {