summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-21 22:35:56 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-21 22:35:56 +0000
commit6ff7e3bae02a466e10006908565dfb606970ede2 (patch)
treefe58d0493323479aa30c3e8c21650b9a4212dadb
parentda4e125ea9e215b7ac47b1079be6b33389c64c27 (diff)
Fix for memory leak when gui is attached, submitted and fixed by GreenReaper, thanks!
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11936 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--win/inspircd_win32wrapper.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/win/inspircd_win32wrapper.cpp b/win/inspircd_win32wrapper.cpp
index bc68a2486..8291cd60d 100644
--- a/win/inspircd_win32wrapper.cpp
+++ b/win/inspircd_win32wrapper.cpp
@@ -652,6 +652,7 @@ int getcpu()
while (pEnumerator)
{
VARIANT vtProp;
+ VariantInit(&vtProp);
/* Next item */
HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn);
@@ -664,9 +665,10 @@ int getcpu()
if (!FAILED(hr))
{
/* Matches our process ID? */
- if (vtProp.uintVal == GetCurrentProcessId())
- {
- VariantClear(&vtProp);
+ UINT pid = vtProp.uintVal;
+ VariantClear(&vtProp);
+ if (pid == GetCurrentProcessId())
+ {
/* Get CPU percentage for this process */
hr = pclsObj->Get(L"PercentProcessorTime", 0, &vtProp, 0, 0);
if (!FAILED(hr))
@@ -674,18 +676,19 @@ int getcpu()
/* Deal with wide string ickyness. Who in their right
* mind puts a number in a bstrVal wide string item?!
*/
- VariantClear(&vtProp);
cpu = 0;
std::wstringstream out(vtProp.bstrVal);
out >> cpu;
- break;
+ VariantClear(&vtProp);
}
+ pclsObj->Release();
+ break;
}
+ pclsObj->Release();
}
}
pEnumerator->Release();
- pclsObj->Release();
}
SysFreeString(Language);