Patch by Heis Spiter <heis_spiter@hotmail.com>:

- Fix a handle leak
See issue #2772 for more details.

svn path=/trunk/; revision=29968
This commit is contained in:
Thomas Bluemel 2007-10-30 01:46:00 +00:00
parent 3e0b11c4bf
commit b9ef3cb742
2 changed files with 8 additions and 3 deletions

View file

@ -137,7 +137,7 @@ void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
RECT rcText;
COLORREF crPrevForeground;
TCHAR Text[260];
HFONT hFont, hOldFont;
HFONT hOldFont;
ULONG CpuUsage;
ULONG CpuKernelUsage;
int nBars;
@ -174,8 +174,7 @@ void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
rcText = rcClient;
InflateRect(&rcText, -2, -2);
crPrevForeground = SetTextColor(hDC, RGB(0, 255, 0));
hFont = GetStockObject(DEFAULT_GUI_FONT);
hOldFont = SelectObject(hDC, hFont);
hOldFont = SelectObject(hDC, GetStockObject(DEFAULT_GUI_FONT));
DrawText(hDC, Text, -1, &rcText, DT_BOTTOM | DT_CENTER | DT_NOPREFIX | DT_SINGLELINE);
SelectObject(hDC, hOldFont);
SetTextColor(hDC, crPrevForeground);
@ -297,6 +296,8 @@ void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
rcBarRight.bottom -=3;
}
SelectObject(hDC, hOldFont);
}
void Graph_DrawMemUsageGraph(HDC hDC, HWND hWnd)
@ -403,6 +404,9 @@ void Graph_DrawMemUsageGraph(HDC hDC, HWND hWnd)
rcBarRight.top += 3;
rcBarRight.bottom += 3;
}
SelectObject(hDC, hOldFont);
DeleteObject(hFont);
}
void Graph_DrawMemUsageHistoryGraph(HDC hDC, HWND hWnd)

View file

@ -74,6 +74,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,
/* Get the debug privilege for this process. */
AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
CloseHandle(hToken);
}
/* Load our settings from the registry */