Author: fireball
Date: Fri Jan 27 22:01:24 2012
New Revision: 55266
URL:
http://svn.reactos.org/svn/reactos?rev=55266&view=rev
Log:
Fix a dcattr memory leak. Similar leak was already fixed in trunk in bug 6119. Huge
(really!) thanks goes to igorko for finding all related fixes in trunk, for
regress-testing the issue and finding the one and only, absolutely correct, guilty
revision. After that, fixing it was just a few minutes work.
Modified:
branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c [iso-8859-1] Fri Jan 27
22:01:24 2012
@@ -99,6 +99,33 @@
DC_UnlockDc(pDC);
}
+VOID
+FASTCALL
+DC_FreeDcAttr(HDC DCToFree)
+{
+ NTSTATUS Status;
+ SIZE_T Size = 0;
+
+ PDC pDC = DC_LockDc(DCToFree);
+ if (pDC->pdcattr == NULL) return; // Internal DC object!
+ pDC->pdcattr = NULL;
+ DC_UnlockDc(pDC);
+
+ {
+ INT Index = GDI_HANDLE_GET_INDEX((HGDIOBJ)DCToFree);
+ PGDI_TABLE_ENTRY Entry = &GdiHandleTable->Entries[Index];
+ if (Entry->UserData)
+ {
+ Status = ZwFreeVirtualMemory(NtCurrentProcess(), &Entry->UserData,
&Size, MEM_RELEASE);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Failed freeing dcattr memory with Status 0x%08X\n",
Status);
+ }
+ Entry->UserData = NULL;
+ }
+ }
+}
+
BOOL APIENTRY RosGdiCreateDC( HDC *pdev, LPCWSTR driver, LPCWSTR device,
LPCWSTR output, const DEVMODEW* initData, ULONG dcType )
{
@@ -120,7 +147,7 @@
pNewDC->ppdev = (PVOID)&PrimarySurface;
/* Allocate dc shared memory */
- DC_AllocateDcAttr(hNewDC);
+ DC_AllocateDcAttr(hNewDC);
/* Set default fg/bg colors */
pNewDC->crBackgroundClr = RGB(255, 255, 255);
@@ -191,6 +218,9 @@
BOOL APIENTRY RosGdiDeleteDC( HDC physDev )
{
DPRINT("RosGdiDeleteDC(%x)\n", physDev);
+
+ /* Free DC attr */
+ DC_FreeDcAttr(physDev);
/* Free DC */
GDIOBJ_FreeObjByHandle(physDev, GDI_OBJECT_TYPE_DC);