Author: tkreuzer Date: Sat Aug 21 19:55:09 2010 New Revision: 48579
URL: http://svn.reactos.org/svn/reactos?rev=48579&view=rev Log: [WIN32K] - Allocate the DCs prgnVis in DC_AllocDC, instead of "on demand" in GdiSelectVisRgn and properly handle failure case. This fixes a possible crash, when running out of gdi handles.
Modified: trunk/reactos/subsystems/win32/win32k/objects/cliprgn.c trunk/reactos/subsystems/win32/win32k/objects/dclife.c
Modified: trunk/reactos/subsystems/win32/win32k/objects/cliprgn.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/obj... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/cliprgn.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/objects/cliprgn.c [iso-8859-1] Sat Aug 21 19:55:09 2010 @@ -107,11 +107,7 @@
dc->fs &= ~DC_FLAG_DIRTY_RAO;
- if (dc->prgnVis == NULL) - { - dc->prgnVis = IntSysCreateRectpRgn(0, 0, 0, 0); - GDIOBJ_CopyOwnership(hdc, ((PROSRGNDATA)dc->prgnVis)->BaseObject.hHmgr); - } + ASSERT (dc->prgnVis != NULL);
retval = NtGdiCombineRgn(((PROSRGNDATA)dc->prgnVis)->BaseObject.hHmgr, hrgn, 0, RGN_COPY); if ( retval != ERROR )
Modified: trunk/reactos/subsystems/win32/win32k/objects/dclife.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/obj... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/dclife.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/objects/dclife.c [iso-8859-1] Sat Aug 21 19:55:09 2010 @@ -48,6 +48,18 @@ }
hDC = NewDC->BaseObject.hHmgr; + + /* Allocate a Vis region */ + NewDC->prgnVis = IntSysCreateRectpRgn(0, 0, 1, 1); + if (!NewDC->prgnVis) + { + DPRINT1("IntSysCreateRectpRgn failed\n"); + if (!GDIOBJ_FreeObjByHandle(hDC, GDI_OBJECT_TYPE_DC)) + { + ASSERT(FALSE); + } + return NULL; + }
NewDC->pdcattr = &NewDC->dcattr; DC_AllocateDcAttr(hDC); @@ -661,7 +673,6 @@ PDC pdcNew, pdcOld; PDC_ATTR pdcattrNew, pdcattrOld; HDC hdcNew, DisplayDC = NULL; - HRGN hVisRgn; UNICODE_STRING DriverName; DWORD Layout = 0; HSURF hsurf; @@ -742,12 +753,6 @@ NtGdiDeleteObjectApp(DisplayDC); }
- hVisRgn = IntSysCreateRectRgn(0, 0, 1, 1); - if (hVisRgn) - { - GdiSelectVisRgn(hdcNew, hVisRgn); - REGION_FreeRgnByHandle(hVisRgn); - } if (Layout) NtGdiSetLayout(hdcNew, -1, Layout);
DC_InitDC(hdcNew);